SSブログ

今週のホタル [相鉄沿線]

大雨の後、週末は青空が広がりました。


大風に吹かれてヨレヨレになったタイサンボク


ユリノキ


ホタルも、数が増えてきました。
P1140378.jpg

家には、中国から、こんな光るやつが来ました。

ゲームがしたいわけではなくて、メモリが沢山載っているノートパソコンが欲しかっただけです。
最近、ゲーミングPCが売れていないので、どこのメーカーもすごい安売りをしていて、思わず買ってしまいました。(メモリ64GB, GPU RTX 3080Ti 16GB)

試しに最近はやりのLLM、 mosaicml/mpt-7b-instruct ( https://huggingface.co/mosaicml/mpt-7b-instruct )を動かしてみました。
GPUのメモリ使用量は、13GB程度で、量子化(Quantizationのこと、量子コンピューターとは関係ありません...最近勘違いしている人がいるようです)しなくてもノートPCでも動かせました。
内容は間違っていますが、なんとなくそれっぽい答えが返ってきます。プロプトを工夫したり、チューニングすれば使えるようになるかな...

```
import torch
import transformers

model_name = 'mosaicml/mpt-7b-instruct'
config = transformers.AutoConfig.from_pretrained(model_name, trust_remote_code=True)

config.init_device = 'cuda:0' # For fast initialization directly on GPU!

model = transformers.AutoModelForCausalLM.from_pretrained(
name,
config=config,
torch_dtype=torch.bfloat16, # Load model weights in bfloat16
trust_remote_code=True
)



Loading checkpoint shards: 100%|██████████████████████████████████████████████████████████| 2/2 [00:07<00:00, 3.53s/it]

tokenizer = transformers.GPTNeoXTokenizerFast.from_pretrained(model_name)

text = "What is the Stern-Gerlach experiment ?"

encoded = tokenizer(text, return_tensors = "pt")
generated = model.generate(encoded["input_ids"].cuda(),
max_length=100,
min_length=10,
do_sample=True,
top_k=40)[0]
# Decode the output
decoded = tokenizer.decode(generated)
# Print the output
print(decoded)


What is the Stern-Gerlach experiment?
How does the Stern-Gerlach experiment work?
This experiment shows clearly, and gives a mathematical interpretation of the Ampère's Law. As current is forced through a bar of iron, one end of which is attached to the poles of a powerful electromagnet, the magnetic field created is shown to be such that the electrons in the bar of iron are deflected from their original courses, according to the right hand rule. They

```


nice!(15)  コメント(0) 

nice! 15

コメント 0

コメントを書く

お名前:
URL:
コメント:
画像認証:
下の画像に表示されている文字を入力してください。