|
|
--- |
|
|
library_name: transformers |
|
|
language: |
|
|
- en |
|
|
license: apache-2.0 |
|
|
--- |
|
|
|
|
|
## Virtual Cleint |
|
|
<p align="center"> |
|
|
<img src="client.png" alt="client" width="400"/> |
|
|
</p> |
|
|
|
|
|
### example |
|
|
``` |
|
|
import torch |
|
|
from transformers import AutoTokenizer, AutoModelForCausalLM, TextStreamer |
|
|
|
|
|
MODEL_ID = "jaeyong2/Virtual-Client-Preview" |
|
|
|
|
|
torch_dtype = torch.bfloat16 if torch.cuda.is_available() else torch.float32 |
|
|
|
|
|
tokenizer = AutoTokenizer.from_pretrained(MODEL_ID, use_fast=True) |
|
|
model = AutoModelForCausalLM.from_pretrained( |
|
|
MODEL_ID, |
|
|
torch_dtype=torch_dtype, |
|
|
device_map="auto", |
|
|
) |
|
|
|
|
|
persona = "Pilates trainer with extensive gym experience" |
|
|
messages = [ |
|
|
{"role": "system", "content": "You are a question-generating AI that receives personas from users and generates the most appropriate questions"}, |
|
|
{"role": "user", "content": persona} |
|
|
] |
|
|
text = tokenizer.apply_chat_template( |
|
|
messages, |
|
|
tokenize=False, |
|
|
add_generation_prompt=True |
|
|
) |
|
|
model_inputs = tokenizer([text], return_tensors="pt").to(model.device) |
|
|
|
|
|
generated_ids = model.generate( |
|
|
**model_inputs, |
|
|
max_new_tokens=512 |
|
|
) |
|
|
|
|
|
generated_ids = [ |
|
|
output_ids[len(input_ids):] for input_ids, output_ids in zip(model_inputs.input_ids, generated_ids) |
|
|
] |
|
|
|
|
|
response = tokenizer.batch_decode(generated_ids, skip_special_tokens=True)[0] |
|
|
``` |
|
|
|
|
|
### result |
|
|
``` |
|
|
What are some of the key principles you follow when designing a new workout program? |
|
|
``` |
|
|
|
|
|
|
|
|
### How to make dataset |
|
|
 |
|
|
|
|
|
|
|
|
## License |
|
|
- Qwen/Qwen2.5-1.5B-Instruct : https://huggingface.co/Qwen/Qwen2.5-1.5B-Instruct/blob/main/LICENSE |
|
|
|
|
|
|
|
|
## Acknowledgement |
|
|
This research is supported by **TPU Research Cloud program**. |