Downloads · 30 days
0
dawang123/llama-8b-chineseAMR-multitask
llama-8b-chineseAMR-multitask is a machine learning model from dawang123. Use it for the machine learning task on the model card, and read the license before you ship it in a product. The card lists the license as apache-2.0.
from transformers import AutoModelForCausalLM, AutoTokenizer from peft import PeftModel
Downloads · 30 days
0
Access
Public
Updated Aug 8, 2025
Repo size
185 MB
Likes
0
Public
Click a slice to open those files.
.safetensors168 MB · 83%
From the Hugging Face model README
from transformers import AutoModelForCausalLM, AutoTokenizer
from peft import PeftModel
# Load base model and tokenizer
base_model_path = "meta-llama/Llama-3.1-8B" # or your local path
adapter_path = "dawang123/llama-8b-chineseAMR-multitask"
tokenizer = AutoTokenizer.from_pretrained(base_model_path)
model = AutoModelForCausalLM.from_pretrained(
base_model_path,
device_map="auto"
)
model = PeftModel.from_pretrained(model, adapter_path, device_map="auto")
# Input text with variant words
input_text = "小糖人都是可以吃的。"
# Instruction for the task
instruction = "请将以下句子中的变体词进行还原。注意,只修改变体词,其他内容(包括可能的语音识别错误)保持不变。"
# Format as chat template
messages = [
{"role": "user", "content": f"{instruction}\n{input_text}"}
]
prompt = tokenizer.apply_chat_template(messages, tokenize=False, add_generation_prompt=True)
# Tokenize and generate
inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
outputs = model.generate(**inputs, max_new_tokens=128)
# Decode and clean response
response = tokenizer.decode(outputs[0], skip_special_tokens=True)
print("Input:", input_text)
print("Corrected output:", generated_text)