Text Generation
Transformers
Safetensors
qwen2
conversational
Eval Results (legacy)
Eval Results
text-generation-inference
Instructions to use FlameF0X/Qwen2-0.2B-it with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use FlameF0X/Qwen2-0.2B-it with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="FlameF0X/Qwen2-0.2B-it") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("FlameF0X/Qwen2-0.2B-it") model = AutoModelForCausalLM.from_pretrained("FlameF0X/Qwen2-0.2B-it", device_map="auto") 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]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use FlameF0X/Qwen2-0.2B-it with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "FlameF0X/Qwen2-0.2B-it" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "FlameF0X/Qwen2-0.2B-it", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/FlameF0X/Qwen2-0.2B-it
- SGLang
How to use FlameF0X/Qwen2-0.2B-it 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 "FlameF0X/Qwen2-0.2B-it" \ --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": "FlameF0X/Qwen2-0.2B-it", "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 "FlameF0X/Qwen2-0.2B-it" \ --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": "FlameF0X/Qwen2-0.2B-it", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use FlameF0X/Qwen2-0.2B-it with Docker Model Runner:
docker model run hf.co/FlameF0X/Qwen2-0.2B-it
Update README.md
Browse files
README.md
CHANGED
|
@@ -24,8 +24,8 @@ model-index:
|
|
| 24 |
type: text-generation
|
| 25 |
name: Text Generation
|
| 26 |
dataset:
|
| 27 |
-
name:
|
| 28 |
-
type:
|
| 29 |
config: main
|
| 30 |
split: test
|
| 31 |
metrics:
|
|
@@ -40,7 +40,7 @@ model-index:
|
|
| 40 |
type: text-generation
|
| 41 |
name: Text Generation
|
| 42 |
dataset:
|
| 43 |
-
name:
|
| 44 |
type: TIGER-Lab/MMLU-Pro
|
| 45 |
config: default
|
| 46 |
split: test
|
|
@@ -53,37 +53,72 @@ model-index:
|
|
| 53 |
name: Local Benchmark
|
| 54 |
url: https://huggingface.co/FlameF0X/Qwen2-0.2B-it
|
| 55 |
---
|
| 56 |
-
|
| 57 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 58 |
import torch
|
| 59 |
from transformers import AutoTokenizer, AutoModelForCausalLM
|
|
|
|
| 60 |
model_path = "FlameF0X/Qwen2-0.2B-it"
|
|
|
|
| 61 |
tokenizer = AutoTokenizer.from_pretrained(model_path, trust_remote_code=True)
|
| 62 |
model = AutoModelForCausalLM.from_pretrained(
|
| 63 |
-
model_path,
|
| 64 |
-
torch_dtype="auto",
|
| 65 |
device_map="auto",
|
| 66 |
trust_remote_code=True
|
| 67 |
)
|
|
|
|
| 68 |
messages = [
|
| 69 |
{"role": "system", "content": "You are a helpful assistant."},
|
| 70 |
{"role": "user", "content": "Explain how a transformer model works in one sentence."}
|
| 71 |
]
|
|
|
|
| 72 |
text = tokenizer.apply_chat_template(
|
| 73 |
-
messages,
|
| 74 |
-
tokenize=False,
|
| 75 |
add_generation_prompt=True
|
| 76 |
)
|
|
|
|
| 77 |
model_inputs = tokenizer([text], return_tensors="pt").to(model.device)
|
|
|
|
| 78 |
generated_ids = model.generate(
|
| 79 |
**model_inputs,
|
| 80 |
max_new_tokens=128,
|
| 81 |
do_sample=True,
|
| 82 |
temperature=0.7
|
| 83 |
)
|
|
|
|
| 84 |
generated_ids = [
|
| 85 |
-
output_ids[len(input_ids):]
|
|
|
|
| 86 |
]
|
|
|
|
| 87 |
response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
|
| 88 |
print(f"--- Assistant Response ---\n{response}")
|
| 89 |
-
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 24 |
type: text-generation
|
| 25 |
name: Text Generation
|
| 26 |
dataset:
|
| 27 |
+
name: GSM8K
|
| 28 |
+
type: gsm8k
|
| 29 |
config: main
|
| 30 |
split: test
|
| 31 |
metrics:
|
|
|
|
| 40 |
type: text-generation
|
| 41 |
name: Text Generation
|
| 42 |
dataset:
|
| 43 |
+
name: MMLU-Pro
|
| 44 |
type: TIGER-Lab/MMLU-Pro
|
| 45 |
config: default
|
| 46 |
split: test
|
|
|
|
| 53 |
name: Local Benchmark
|
| 54 |
url: https://huggingface.co/FlameF0X/Qwen2-0.2B-it
|
| 55 |
---
|
| 56 |
+
|
| 57 |
+
## Evaluation Results
|
| 58 |
+
|
| 59 |
+
| Benchmark | Score |
|
| 60 |
+
|-----------|-------|
|
| 61 |
+
| GSM8K (test) | 2.00% |
|
| 62 |
+
| MMLU-Pro (test) | 4.00% |
|
| 63 |
+
|
| 64 |
+
> Results obtained via local evaluation. Given the model size (0.2B parameters), low benchmark scores are expected.
|
| 65 |
+
|
| 66 |
+
## Model Usage
|
| 67 |
+
```python
|
| 68 |
import torch
|
| 69 |
from transformers import AutoTokenizer, AutoModelForCausalLM
|
| 70 |
+
|
| 71 |
model_path = "FlameF0X/Qwen2-0.2B-it"
|
| 72 |
+
|
| 73 |
tokenizer = AutoTokenizer.from_pretrained(model_path, trust_remote_code=True)
|
| 74 |
model = AutoModelForCausalLM.from_pretrained(
|
| 75 |
+
model_path,
|
| 76 |
+
torch_dtype="auto",
|
| 77 |
device_map="auto",
|
| 78 |
trust_remote_code=True
|
| 79 |
)
|
| 80 |
+
|
| 81 |
messages = [
|
| 82 |
{"role": "system", "content": "You are a helpful assistant."},
|
| 83 |
{"role": "user", "content": "Explain how a transformer model works in one sentence."}
|
| 84 |
]
|
| 85 |
+
|
| 86 |
text = tokenizer.apply_chat_template(
|
| 87 |
+
messages,
|
| 88 |
+
tokenize=False,
|
| 89 |
add_generation_prompt=True
|
| 90 |
)
|
| 91 |
+
|
| 92 |
model_inputs = tokenizer([text], return_tensors="pt").to(model.device)
|
| 93 |
+
|
| 94 |
generated_ids = model.generate(
|
| 95 |
**model_inputs,
|
| 96 |
max_new_tokens=128,
|
| 97 |
do_sample=True,
|
| 98 |
temperature=0.7
|
| 99 |
)
|
| 100 |
+
|
| 101 |
generated_ids = [
|
| 102 |
+
output_ids[len(input_ids):]
|
| 103 |
+
for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids)
|
| 104 |
]
|
| 105 |
+
|
| 106 |
response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0]
|
| 107 |
print(f"--- Assistant Response ---\n{response}")
|
| 108 |
+
```
|
| 109 |
+
|
| 110 |
+
## Training Data
|
| 111 |
+
|
| 112 |
+
This model was instruction-tuned on a mixture of:
|
| 113 |
+
|
| 114 |
+
- `Salesforce/wikitext` β General text
|
| 115 |
+
- `roneneldan/TinyStories` β Short story generation
|
| 116 |
+
- `FlameF0X/arXiv-AI-ML` β AI/ML research papers
|
| 117 |
+
- `Skylion007/openwebtext` β Web text
|
| 118 |
+
- `flytech/python-codes-25k` β Python code
|
| 119 |
+
- `bookcorpus/bookcorpus` β Books
|
| 120 |
+
- `HuggingFaceH4/ultrachat_200k` β Instruction following
|
| 121 |
+
- `openai/gsm8k` β Math reasoning
|
| 122 |
+
- `microsoft/orca-math-word-problems-200k` β Math word problems
|
| 123 |
+
- `laion/OIG` β Open instruction generalist
|
| 124 |
+
- `microsoft/wiki_qa` β Question answering
|