初始化项目,由ModelHub XC社区提供模型
Model: bfuzzy1/acheron-m Source: Original Platform
This commit is contained in:
48
README.md
Normal file
48
README.md
Normal file
@@ -0,0 +1,48 @@
|
||||
---
|
||||
tags:
|
||||
- autotrain
|
||||
- text-generation-inference
|
||||
- text-generation
|
||||
library_name: transformers
|
||||
base_model: bfuzzy1/acheron-d
|
||||
widget:
|
||||
- messages:
|
||||
- role: user
|
||||
content: What is your favorite condiment?
|
||||
license: other
|
||||
datasets:
|
||||
- eth-dl-rewards/math-problems-for-sft
|
||||
---
|
||||
|
||||
# The M is for Math.
|
||||
|
||||
# Usage
|
||||
|
||||
```python
|
||||
|
||||
from transformers import AutoModelForCausalLM, AutoTokenizer
|
||||
import torch
|
||||
|
||||
model_path = "bfuzzy1/acheron-m"
|
||||
|
||||
tokenizer = AutoTokenizer.from_pretrained(model_path)
|
||||
model = AutoModelForCausalLM.from_pretrained(
|
||||
model_path,
|
||||
device_map="auto",
|
||||
torch_dtype='auto',
|
||||
trust_remote_code=True
|
||||
)
|
||||
|
||||
messages = [
|
||||
{"role": "user", "content": "What's 2 + 2 -3?"}
|
||||
]
|
||||
|
||||
input_ids = tokenizer.apply_chat_template(conversation=messages, tokenize=True, add_generation_prompt=True, return_tensors='pt')
|
||||
output_ids = model.generate(
|
||||
input_ids.to('mps' if torch.backends.mps.is_available() else 'cpu'),
|
||||
max_new_tokens=100
|
||||
)
|
||||
response = tokenizer.decode(output_ids[0][input_ids.shape[1]:], skip_special_tokens=True)
|
||||
|
||||
print(response)
|
||||
```
|
||||
Reference in New Issue
Block a user