1.3 KiB
1.3 KiB
base_model, tags, license, language
| base_model | tags | license | language | |||||
|---|---|---|---|---|---|---|---|---|
| unsloth/Qwen3-8B |
|
apache-2.0 |
|
from transformers import AutoModelForCausalLM, AutoTokenizer
model_name = "azherali/Aqal-1.0-8B"
# load the tokenizer and the model
tokenizer = AutoTokenizer.from_pretrained(model_name)
model = AutoModelForCausalLM.from_pretrained(
model_name,
torch_dtype="auto",
device_map="auto"
)
# prepare the model input
prompt = "پاکستان کی ثقافت کے بارے میں مختصر وضاحت کریں۔"
messages = [
{"role": "user", "content": prompt}
]
text = tokenizer.apply_chat_template(
messages,
tokenize=False,
add_generation_prompt=True,
)
model_inputs = tokenizer([text], return_tensors="pt").to(model.device)
# conduct text completion
generated_ids = model.generate(
**model_inputs,
max_new_tokens=2048
)
output_ids = generated_ids[0][len(model_inputs.input_ids[0]):].tolist()
try:
# rindex finding 151668 (</think>)
index = len(output_ids) - output_ids[::-1].index(151668)
except ValueError:
index = 0
content = tokenizer.decode(
output_ids[index:],
skip_special_tokens=True
).strip("\n")
print("content:", content)
Uploaded model
- Developed by: azherali
- License: apache-2.0