Text Generation
Transformers
Safetensors
Uzbek
English
qwen3_5_text
qwen3.5
uzbek
conversational
translation
text-generation-inference
Instructions to use NeuronUz/NeuronAI-2B with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use NeuronUz/NeuronAI-2B with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="NeuronUz/NeuronAI-2B") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("NeuronUz/NeuronAI-2B") model = AutoModelForCausalLM.from_pretrained("NeuronUz/NeuronAI-2B", 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 NeuronUz/NeuronAI-2B with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "NeuronUz/NeuronAI-2B" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "NeuronUz/NeuronAI-2B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/NeuronUz/NeuronAI-2B
- SGLang
How to use NeuronUz/NeuronAI-2B 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 "NeuronUz/NeuronAI-2B" \ --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": "NeuronUz/NeuronAI-2B", "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 "NeuronUz/NeuronAI-2B" \ --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": "NeuronUz/NeuronAI-2B", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use NeuronUz/NeuronAI-2B with Docker Model Runner:
docker model run hf.co/NeuronUz/NeuronAI-2B
Fix inference example and multi-GPU device placement
Browse files
README.md
CHANGED
|
@@ -56,12 +56,14 @@ import torch
|
|
| 56 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 57 |
|
| 58 |
model_id = "NeuronUz/qwen3.5-2b-fine-tuned"
|
|
|
|
| 59 |
|
| 60 |
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
| 61 |
model = AutoModelForCausalLM.from_pretrained(
|
| 62 |
model_id,
|
| 63 |
torch_dtype="auto",
|
| 64 |
-
|
|
|
|
| 65 |
)
|
| 66 |
|
| 67 |
messages = [
|
|
@@ -73,26 +75,31 @@ inputs = tokenizer.apply_chat_template(
|
|
| 73 |
messages,
|
| 74 |
add_generation_prompt=True,
|
| 75 |
return_tensors="pt",
|
|
|
|
| 76 |
).to(model.device)
|
| 77 |
|
| 78 |
with torch.inference_mode():
|
| 79 |
output = model.generate(
|
| 80 |
-
inputs,
|
| 81 |
max_new_tokens=256,
|
| 82 |
-
do_sample=
|
| 83 |
-
temperature=0.7,
|
| 84 |
-
top_p=0.9,
|
| 85 |
)
|
| 86 |
|
| 87 |
-
|
|
|
|
| 88 |
```
|
| 89 |
|
| 90 |
Use a recent Transformers release with Qwen3.5 support.
|
| 91 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 92 |
## Limitations
|
| 93 |
|
| 94 |
The model may produce inaccurate, biased, or fabricated information. It has not
|
| 95 |
been comprehensively evaluated for safety or high-stakes domains. Outputs should
|
| 96 |
be independently verified before use in medical, legal, financial, or other
|
| 97 |
consequential settings.
|
| 98 |
-
|
|
|
|
| 56 |
from transformers import AutoModelForCausalLM, AutoTokenizer
|
| 57 |
|
| 58 |
model_id = "NeuronUz/qwen3.5-2b-fine-tuned"
|
| 59 |
+
device = "cuda:0" if torch.cuda.is_available() else "cpu"
|
| 60 |
|
| 61 |
tokenizer = AutoTokenizer.from_pretrained(model_id)
|
| 62 |
model = AutoModelForCausalLM.from_pretrained(
|
| 63 |
model_id,
|
| 64 |
torch_dtype="auto",
|
| 65 |
+
# Keep this hybrid model on one device. See the note below.
|
| 66 |
+
device_map=device,
|
| 67 |
)
|
| 68 |
|
| 69 |
messages = [
|
|
|
|
| 75 |
messages,
|
| 76 |
add_generation_prompt=True,
|
| 77 |
return_tensors="pt",
|
| 78 |
+
return_dict=True,
|
| 79 |
).to(model.device)
|
| 80 |
|
| 81 |
with torch.inference_mode():
|
| 82 |
output = model.generate(
|
| 83 |
+
**inputs,
|
| 84 |
max_new_tokens=256,
|
| 85 |
+
do_sample=False,
|
|
|
|
|
|
|
| 86 |
)
|
| 87 |
|
| 88 |
+
prompt_length = inputs["input_ids"].shape[-1]
|
| 89 |
+
print(tokenizer.decode(output[0][prompt_length:], skip_special_tokens=True))
|
| 90 |
```
|
| 91 |
|
| 92 |
Use a recent Transformers release with Qwen3.5 support.
|
| 93 |
|
| 94 |
+
When multiple GPUs are visible, avoid `device_map="auto"` with this checkpoint.
|
| 95 |
+
Current Accelerate/Transformers releases may split the Qwen3.5 hybrid layers
|
| 96 |
+
across GPUs and produce invalid text. Pin the complete model to one GPU as shown
|
| 97 |
+
above. If sampling is desired, a tested starting point is `temperature=0.7`,
|
| 98 |
+
`top_p=0.8`, and `top_k=20`.
|
| 99 |
+
|
| 100 |
## Limitations
|
| 101 |
|
| 102 |
The model may produce inaccurate, biased, or fabricated information. It has not
|
| 103 |
been comprehensively evaluated for safety or high-stakes domains. Outputs should
|
| 104 |
be independently verified before use in medical, legal, financial, or other
|
| 105 |
consequential settings.
|
|
|