Text Generation
Transformers
Safetensors
English
Korean
llama
conversational
text-generation-inference
Instructions to use Bllossom/llama-3.2-Korean-Bllossom-3B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use Bllossom/llama-3.2-Korean-Bllossom-3B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="Bllossom/llama-3.2-Korean-Bllossom-3B") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForMultimodalLM tokenizer = AutoTokenizer.from_pretrained("Bllossom/llama-3.2-Korean-Bllossom-3B") model = AutoModelForMultimodalLM.from_pretrained("Bllossom/llama-3.2-Korean-Bllossom-3B") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Inference
- Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use Bllossom/llama-3.2-Korean-Bllossom-3B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "Bllossom/llama-3.2-Korean-Bllossom-3B" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Bllossom/llama-3.2-Korean-Bllossom-3B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/Bllossom/llama-3.2-Korean-Bllossom-3B
- SGLang
How to use Bllossom/llama-3.2-Korean-Bllossom-3B with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "Bllossom/llama-3.2-Korean-Bllossom-3B" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Bllossom/llama-3.2-Korean-Bllossom-3B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "Bllossom/llama-3.2-Korean-Bllossom-3B" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "Bllossom/llama-3.2-Korean-Bllossom-3B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use Bllossom/llama-3.2-Korean-Bllossom-3B with Docker Model Runner:
docker model run hf.co/Bllossom/llama-3.2-Korean-Bllossom-3B
Update README.md
Browse files
README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
| 2 |
import torch
|
| 3 |
from transformers import AutoTokenizer, AutoModelForCausalLM
|
| 4 |
|
| 5 |
-
model_id = '
|
| 6 |
|
| 7 |
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
| 8 |
model = AutoModelForCausalLM.from_pretrained(
|
|
@@ -10,17 +10,17 @@ model = AutoModelForCausalLM.from_pretrained(
|
|
| 10 |
torch_dtype=torch.bfloat16,
|
| 11 |
device_map="auto",
|
| 12 |
)
|
| 13 |
-
instruction = "
|
| 14 |
|
| 15 |
messages = [
|
| 16 |
{"role": "user", "content": f"{instruction}"}
|
| 17 |
]
|
| 18 |
|
| 19 |
-
|
| 20 |
-
messages,
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
|
| 25 |
terminators = [
|
| 26 |
tokenizer.convert_tokens_to_ids("<|end_of_text|>"),
|
|
@@ -28,58 +28,22 @@ terminators = [
|
|
| 28 |
]
|
| 29 |
|
| 30 |
outputs = model.generate(
|
| 31 |
-
|
| 32 |
-
max_new_tokens=
|
| 33 |
eos_token_id=terminators,
|
| 34 |
do_sample=True,
|
| 35 |
temperature=0.6,
|
| 36 |
top_p=0.9
|
| 37 |
)
|
| 38 |
|
| 39 |
-
print(tokenizer.decode(outputs[0][
|
| 40 |
```
|
| 41 |
```
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
### 서울 관광 코스: 문화와 역사, 현대와 전통을 한 곳에
|
| 45 |
-
|
| 46 |
-
#### 1. 인사동
|
| 47 |
-
- **가장 먼저 방문할 곳:** 인사동
|
| 48 |
-
- **추천 관광지:**
|
| 49 |
-
- **인사동 상상공원:** 서울에서 가장 인기가 있는 상상공원 중 하나로, 다양한 상점과 식당들이 모여 있어 관광객에게 인기가 많습니다.
|
| 50 |
-
- **인사동 가게:** 다양한 음식점과 카페, 전통 가게들이 모여 있어 다양한 맛을 즐길 수 있습니다.
|
| 51 |
-
|
| 52 |
-
#### 2. 명동
|
| 53 |
-
- **가장 먼저 방문할 곳:** 명동
|
| 54 |
-
- **추천 관광지:**
|
| 55 |
-
- **명동 광장:** 서울에서 가장 유명한 광장 중 하나로, 다양한 관광객들이 모여서 관광하기 좋습니다.
|
| 56 |
-
- **명동 가게:** 전통 음식점, 카페, 전통 가게들이 모여 있어 다양한 맛을 즐길 수 있습니다.
|
| 57 |
-
|
| 58 |
-
#### 3. 홍대
|
| 59 |
-
- **가장 먼저 방문할 곳:** 홍대
|
| 60 |
-
- **추천 관광지:**
|
| 61 |
-
- **홍대 광장:** 홍대는 서울의 대표적인 청년 문화와 nightlife가 있는 지역으로, 다양한 관광객들이 모여서 관광하기 좋습니다.
|
| 62 |
-
- **홍대 가게:** 다양한 음식점, 카페, 클럽, 카페가 모여 있어 다양한 경험을 즐길 수 있습니다.
|
| 63 |
-
|
| 64 |
-
#### 4. 서울의 전통 district
|
| 65 |
-
- **가장 먼저 방문할 곳:** 중동, 경복궁, 경복궁 광장
|
| 66 |
-
- **추천 관광지:**
|
| 67 |
-
- **중동:** 전통의 재현을 통해 서울의 역사와 문화를 경험할 수 있는 곳으로, 다양한 전통 가게와 음식점이 모여 있습니다.
|
| 68 |
-
- **경복궁:** 서울의 역사와 문화를 경험할 수 있는 곳으로, 다양한 관광객들이 모여서 관광하기 좋습니다.
|
| 69 |
-
- **경복궁 광장:** 서울에서 가장 큰 광장 중 하나로, 다양한 관광객들이 모여서 관광하기 좋습니다.
|
| 70 |
|
| 71 |
-
|
| 72 |
-
- **가장 먼저 방문할 곳:** 강남, 세종대도
|
| 73 |
-
- **추천 관광지:**
|
| 74 |
-
- **강남:** 서울의 현대가로, 다양한 상업 거리와 관광지들이 모여 있습니다.
|
| 75 |
-
- **세종대도:** 서울의 현대가로, 다양한 상업 거리와 관광지들이 모여 있습니다.
|
| 76 |
|
| 77 |
-
|
| 78 |
-
1. **인사동:** 상상공원, 인사동 가게
|
| 79 |
-
2. **명동:** 명동 광장, 명동 가게
|
| 80 |
-
3. **홍대:** 홍대 광장, 홍대 가게
|
| 81 |
-
4. **서울의 전통 district:** 중동, 경복궁, 경복궁 광장
|
| 82 |
-
5. **서울의 현대가:** 강남, 세종대도
|
| 83 |
|
| 84 |
-
|
| 85 |
```
|
|
|
|
| 2 |
import torch
|
| 3 |
from transformers import AutoTokenizer, AutoModelForCausalLM
|
| 4 |
|
| 5 |
+
model_id = 'Bllossom/llama-3.2-Korean-Bllossom-3B'
|
| 6 |
|
| 7 |
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
| 8 |
model = AutoModelForCausalLM.from_pretrained(
|
|
|
|
| 10 |
torch_dtype=torch.bfloat16,
|
| 11 |
device_map="auto",
|
| 12 |
)
|
| 13 |
+
instruction = "철수가 20개의 연필을 가지고 있었는데 영희가 절반을 가져가고 민수가 남은 5개를 가져갔으면 철수에게 남은 연필의 갯수는 몇개인가요?"
|
| 14 |
|
| 15 |
messages = [
|
| 16 |
{"role": "user", "content": f"{instruction}"}
|
| 17 |
]
|
| 18 |
|
| 19 |
+
input_ids = tokenizer.apply_chat_template(
|
| 20 |
+
messages,
|
| 21 |
+
add_generation_prompt=True,
|
| 22 |
+
return_tensors="pt"
|
| 23 |
+
).to(model.device)
|
| 24 |
|
| 25 |
terminators = [
|
| 26 |
tokenizer.convert_tokens_to_ids("<|end_of_text|>"),
|
|
|
|
| 28 |
]
|
| 29 |
|
| 30 |
outputs = model.generate(
|
| 31 |
+
input_ids,
|
| 32 |
+
max_new_tokens=1024,
|
| 33 |
eos_token_id=terminators,
|
| 34 |
do_sample=True,
|
| 35 |
temperature=0.6,
|
| 36 |
top_p=0.9
|
| 37 |
)
|
| 38 |
|
| 39 |
+
print(tokenizer.decode(outputs[0][input_ids.shape[-1]:], skip_special_tokens=True))
|
| 40 |
```
|
| 41 |
```
|
| 42 |
+
철수가 20개의 연필을 가지고 있었고 영희가 절반을 가져가면, 영희가 가져간 연필의 갯수는 20 / 2 = 10개입니다.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
|
| 44 |
+
이제 철수가 남은 연필의 갯수를 계산해보겠습니다. 영희가 10개를 가져간 후 철수가 남은 연필의 갯수는 20 - 10 = 10개입니다.
|
|
|
|
|
|
|
|
|
|
|
|
|
| 45 |
|
| 46 |
+
민수가 남은 5개를 가져갔으므로, 철수가 남은 연필의 갯수는 10 - 5 = 5개입니다.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
|
| 48 |
+
따라서 철수가 남은 연필의 갯수는 5개입니다.
|
| 49 |
```
|