T4で動く。
使い方
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
model_id = "microsoft/bitnet-b1.58-2B-4T"
# Load tokenizer and model
tokenizer = AutoTokenizer.from_pretrained(model_id)
model = AutoModelForCausalLM.from_pretrained(
model_id,
torch_dtype=torch.bfloat16
)
# Apply the chat template
messages = [
{"role": "system", "content": "You are a helpful AI assistant."},
{"role": "user", "content": "How are you?"},
]
prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
chat_input = tokenizer(prompt, return_tensors="pt").to(model.device)
# Generate response
chat_outputs = model.generate(**chat_input, max_new_tokens=50)
response = tokenizer.decode(chat_outputs[0][chat_input['input_ids'].shape[-1]:], skip_special_tokens=True) # Decode only the response part
print("\nAssistant Response:", response)
以下の製品をみんなが買いたくなるクールなラップを作って
製品名:Mac Studio (2025) M4 Max
SoC:M4 Max(最大16CPU+40GPU+Neural Engine)
メモリ:36 GB〜128 GB ユニファイドメモリ
ストレージ:512 GB〜8 TB SSD
外部ポート:背面 Thunderbolt 5×4、USB‑A×2、HDMI、10 GbE/前面 USB‑C×2、SDXC
サイズ/重量:7.7″×7.7″×3.7″・約2.8 kg
価格:$1,999〜(日本税込 約27万5千円〜)
発売日:2025年3月12日出荷開始
主な強化点:M2 Max比で最大2倍超のCPU/GPU性能、Thunderbolt 5搭載、静音設計継続
Assistant Response: (Verse 1)
Yo, it's the future, meet the Mac Studio (2025) M4 Max,
With 16 CPUs, 40 GPUs, and a Neural Engine that's a blast.
Unified memory, got 36 to 128 gigabytes,
So you can run all your games, without any inhibitions.
(Chorus)
Mac Studio (2025) M4 Max, it's the king of the scene,
Got the power, got the speed, it's the best machine.
From 512 gigabytes to 8 terabytes,
With Thunderbolt 5 and USB-C, you're ready to begin.
(Verse 2)
On the back, four Thunderbolt 5, for all your data needs,
Two USB-A, HDMI, 10 GbE, for a seamless blend.
On the front, two USB-C, for all your charging needs,
SDXC, it's the future, it's the best it can be.
(Chorus)
Mac Studio (2025) M4 Max, it's the king of the scene,
Got the power, got the speed, it's the best machine.
From 7.7 inches to 7.7 inches, it's got the size,
But don't let the size fool, it's got all you need.
(Bridge)
Up to twice the CPU and GPU, that's what it does best,
With quiet design, it's the perfect fit for the rest.
In Japan, it's 275,000 yen, but worldwide it's a steal,
Mac Studio (2025) M4 Max, it's the future, it's real.
(Chorus)
Mac Studio (2025) M4 Max, it's the king of the scene,
Got the power, got the speed, it's the best machine.
From 7.7 inches to 7.7 inches, it's got the size,
But don't let the size fool, it's got all you need.
(Outro)
So what are you waiting for, get your Mac Studio (2025) M4 Max,
It's the future, it's the best, it's the future, it's the past.
50秒かかった。
🐣
フリーランスエンジニアです。
お仕事のご相談こちらまで
rockyshikoku@gmail.com
Core MLを使ったアプリを作っています。
機械学習関連の情報を発信しています。