Views
No views yet

| Industry | Version | Llama 3.1 8B |
|---|---|---|
| Beauty | bf16 | ContaAI/ContaLLM-Beauty-8B-Instruct |
| Beauty | 8bit | ContaAI/ContaLLM-Beauty-8B-Instruct-8bit |
| Beauty | 4bit | ContaAI/ContaLLM-Beauty-8B-Instruct-4bit |
from transformers import AutoModelForCausalLM
model = AutoModelForCausalLM.from_pretrained("ContaAI/ContaLLM-Beauty-8B-Instruct-8bit")system_prompt = '请根据用户提供的营销需求和其他信息写一篇美妆护肤行业的营销推文。'| Parameter name | Required | Meaning and optional range |
|---|---|---|
| 营销需求 | required | Fill in your marketing requirements, cannot be blank |
| 关键词 | optional | Fill in your marketing keywords, or remove this row from the prompt |
| 话题 | optional | Fill in your marketing topic, or remove this row from the prompt |
| 标签 | optional | Fill in the hashtag, or remove this row from the prompt |
| 营销节点 | optional | Fill in the marketing season, such as Valentine's Day, Christmas, or remove this row from the prompt |
| 人设 | optional | Fill in your character settings, or remove this row from the prompt |
| 相关素材 | optional | Fill in the relevant materials for your marketing needs, or remove this row from the prompt |
| 内容长度 | optional | choices=['较长', '中等', '较短'], choose what you need, or remove this row from the prompt |
user_prompt = """营销需求:美白水乳推荐,推广HBN原白水乳。
关键词:HBN原白水乳
话题: 分享护肤 提亮肤色
标签:爱情、浪漫
话题: 分享护肤 提亮肤色
人设:美白水乳推荐,推广HBN原白水乳。
相关素材:美白水乳推荐,推广HBN原白水乳。
内容长度:较长"""import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
model_name = "ContaAI/ContaLLM-Beauty-8B-Instruct-8bit"
model = AutoModelForCausalLM.from_pretrained(model_name, device_map="auto")
tokenizer = AutoTokenizer.from_pretrained(model_name)
system_prompt = '请根据用户提供的营销需求和其他信息写一篇美妆护肤行业的营销推文。'
user_prompt = """营销需求:美白水乳推荐,推广HBN原白水乳。
关键词:HBN原白水乳
话题: 分享护肤 提亮肤色
标签:爱情、浪漫
话题: 分享护肤 提亮肤色
人设:美白水乳推荐,推广HBN原白水乳。
相关素材:美白水乳推荐,推广HBN原白水乳。
内容长度:较长"""
prompt_template = '''<|begin_of_text|><|start_header_id|>system<|end_header_id|>
{}<|eot_id|><|start_header_id|>user<|end_header_id|>
{}<|eot_id|><|start_header_id|>assistant<|end_header_id|>'''
prompt = prompt_template.format(system_prompt, user_prompt)
tokenized_message = tokenizer(
prompt,
max_length=2048,
return_tensors="pt",
add_special_tokens=False
)
response_token_ids= model.generate(
**tokenized_message,
max_new_tokens=1024,
do_sample=True,
top_p=1.0,
temperature=0.5,
min_length=None,
use_cache=True,
top_k=50,
repetition_penalty=1.2,
length_penalty=1,
)
generated_tokens = response_token_ids[0, tokenized_message['input_ids'].shape[-1]:]
generated_text = tokenizer.decode(generated_tokens, skip_special_tokens=True)
print(generated_text)