43 lines
961 B
Markdown
43 lines
961 B
Markdown
---
|
|
library_name: transformers
|
|
license: apache-2.0
|
|
datasets:
|
|
- Salesforce/wikitext
|
|
- roneneldan/TinyStories
|
|
- FlameF0X/arXiv-AI-ML
|
|
- Skylion007/openwebtext
|
|
- flytech/python-codes-25k
|
|
- bookcorpus/bookcorpus
|
|
---
|
|
|
|
## Model usage
|
|
|
|
```py
|
|
import torch
|
|
from transformers import AutoTokenizer, AutoModelForCausalLM
|
|
|
|
model_path = "FlameF0X/Qwen2-0.2B-pt"
|
|
|
|
tokenizer = AutoTokenizer.from_pretrained(model_path, trust_remote_code=True)
|
|
model = AutoModelForCausalLM.from_pretrained(
|
|
model_path,
|
|
torch_dtype="auto",
|
|
device_map="auto",
|
|
trust_remote_code=True
|
|
)
|
|
|
|
prompt = "The future of Artificial Intelligence is"
|
|
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
|
|
|
|
output_ids = model.generate(
|
|
**inputs,
|
|
max_new_tokens=50,
|
|
do_sample=True,
|
|
temperature=0.7,
|
|
top_p=0.9,
|
|
repetition_penalty=1.1
|
|
)
|
|
|
|
response = tokenizer.decode(output_ids[0], skip_special_tokens=True)
|
|
print(f"--- Base Model Completion ---\n{response}")
|
|
``` |