Instructions to use ContaAI/ContaLLM-Food-Beverage-8B-Instruct with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use ContaAI/ContaLLM-Food-Beverage-8B-Instruct with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="ContaAI/ContaLLM-Food-Beverage-8B-Instruct") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# pip install -U transformers accelerate # Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("ContaAI/ContaLLM-Food-Beverage-8B-Instruct") model = AutoModelForCausalLM.from_pretrained("ContaAI/ContaLLM-Food-Beverage-8B-Instruct", device_map="auto") messages = [ {"role": "user", "content": "Who are you?"}, ] inputs = tokenizer.apply_chat_template( messages, add_generation_prompt=True, tokenize=True, return_dict=True, return_tensors="pt", ).to(model.device) outputs = model.generate(**inputs, max_new_tokens=256) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use ContaAI/ContaLLM-Food-Beverage-8B-Instruct with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "ContaAI/ContaLLM-Food-Beverage-8B-Instruct" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "ContaAI/ContaLLM-Food-Beverage-8B-Instruct", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/ContaAI/ContaLLM-Food-Beverage-8B-Instruct
- SGLang
How to use ContaAI/ContaLLM-Food-Beverage-8B-Instruct with SGLang:
Install from pip and serve model
# Install SGLang from pip: pip install sglang # Start the SGLang server: python3 -m sglang.launch_server \ --model-path "ContaAI/ContaLLM-Food-Beverage-8B-Instruct" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "ContaAI/ContaLLM-Food-Beverage-8B-Instruct", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker images
docker run --gpus all \ --shm-size 32g \ -p 30000:30000 \ -v ~/.cache/huggingface:/root/.cache/huggingface \ --env "HF_TOKEN=<secret>" \ --ipc=host \ lmsysorg/sglang:latest \ python3 -m sglang.launch_server \ --model-path "ContaAI/ContaLLM-Food-Beverage-8B-Instruct" \ --host 0.0.0.0 \ --port 30000 # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:30000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "ContaAI/ContaLLM-Food-Beverage-8B-Instruct", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use ContaAI/ContaLLM-Food-Beverage-8B-Instruct with Docker Model Runner:
docker model run hf.co/ContaAI/ContaLLM-Food-Beverage-8B-Instruct
# pip install -U transformers accelerate
# Load model directly
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("ContaAI/ContaLLM-Food-Beverage-8B-Instruct")
model = AutoModelForCausalLM.from_pretrained("ContaAI/ContaLLM-Food-Beverage-8B-Instruct", device_map="auto")
messages = [
{"role": "user", "content": "Who are you?"},
]
inputs = tokenizer.apply_chat_template(
messages,
add_generation_prompt=True,
tokenize=True,
return_dict=True,
return_tensors="pt",
).to(model.device)
outputs = model.generate(**inputs, max_new_tokens=256)
print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:]))
ContaLLM-Food-Beverage-8B-Instruct
ContaLLM-Food-Beverage-8B-Instruct is a large Chinese vertical marketing model for the food and beverage industry. You can customize and generate marketing texts according to users' specific marketing needs, product selection, product selection knowledge base, keywords, main recommended selling points, main recommended scenes, hashtags, article types, etc. Use the LLM's capabilities and training on existing high-quality marketing materials to help companies generate diversified, high-quality marketing content and improve marketing conversion rates.
Model description
- Model type: A model trained on a mix of publicly available, synthetic and human-annotated datasets.
- Language(s) (NLP): Primarily Chinese
- Industry: Food And Beverage Industry Marketing
- License: Llama 3.1 Community License Agreement
- Finetuned from model: meta-llama/Llama-3.1-8B-Instruct
Model Stage
| Industry | Version | Llama 3.1 8B |
|---|---|---|
| Food And Beverage | bf16 | ContaAI/ContaLLM-Food-Beverage-8B-Instruct |
| Food And Beverage | 8bit | ContaAI/ContaLLM-Food-Beverage-8B-Instruct-8bit |
| Food And Beverage | 4bit | ContaAI/ContaLLM-Food-Beverage-8B-Instruct-4bit |
Using the model
Loading with HuggingFace
To load the model with HuggingFace, use the following snippet:
from transformers import AutoModelForCausalLM
model = AutoModelForCausalLM.from_pretrained("ContaAI/ContaLLM-Food-Beverage-8B-Instruct")
System Prompt
This model is a Chinese marketing model for food and beverage industry, so we use this system prompt by default:
system_prompt = '่ฏทๆ นๆฎ็จๆทๆไพ็่ฅ้้ๆฑใ้ๅๅๅ
ถไปไฟกๆฏๅไธ็ฏ้ฃๅ้ฅฎๆ่กไธ็่ฅ้ๆจๆใ'
User Prompt
Users can enter the required marketing needs according to their own needs, non-required including keywords, topics, label marketing nodes, people, related materials, content length, which content length has three specifications, respectively, shorter, medium, longer. The details are as follows:
| Parameter name | Required | Meaning and optional range |
|---|---|---|
| ่ฅ้้ๆฑ | required | Fill in your marketing requirements, cannot be blank |
| ้ๅ | required | Fill in your product selection, cannot be blank |
| ้ๅ็ฅ่ฏๅบ | required | Fill in the relevant information/materials about your product, cannot be blank |
| ๅ ณ้ฎ่ฏ | optional | Fill in your marketing keywords, or remove this row from the prompt |
| ๆ ็ญพ | optional | Fill in the hashtag, or remove this row from the prompt |
| ไธปๆจๅ็น | optional | Fill in the main recommended selling points, or remove this row from the prompt |
| ไธปๆจๅบๆฏ | optional | Fill in the main recommended scenes, or remove this row from the prompt |
| ๆ็ซ ็ฑปๅ | optional | Fill in the article type, or remove this row from the prompt |
Example:
user_prompt = """่ฅ้้ๆฑ๏ผๅคๆฅๆธ
ๅ๏ผๆฅๆ้ฃๅณไฝ้ช
้ๅ๏ผๆธ
ๆฐๆ ๆชฌๅฏฟๅธๅท
้ๅ็ฅ่ฏๅบ๏ผ1ใ้็จๆฐ้ฒ็ไธๆ้ฑผๅ็ๆฒนๆ๏ผๆญ้
ๆธ
็ฝๆ ๆชฌๆฑ๏ผๅฃๆๅฑๆฌกไธฐๅฏใ2ใไฝ่ๅฅๅบท๏ผ้ๅๅฅ่บซไบบๅฃซใ3ใๆฏไปฝไป
ๅซ200ๅคงๅก๏ผ่ฝปๆพไบซๅ็พๅณใ
ๅ
ณ้ฎ่ฏ๏ผๆฅๆใๅฏฟๅธใๅฅๅบท้ฅฎ้ฃใๅคๆฅ็พ้ฃ
ไธปๆจๅ็น๏ผๆธ
ๆฐๅฅๅบท
ไธปๆจๅบๆฏ๏ผๅคๆฅ่ไผ
ๆ ็ญพ๏ผ#ๆฅๆ# #ๅฏฟๅธ# #ๅฅๅบท็พ้ฃ
ๆ็ซ ็ฑปๅ๏ผ็พ้ฃๆจ่"""
Use example (with template)
import torch
from transformers import AutoModelForCausalLM, AutoTokenizer
model_name = "ContaAI/ContaLLM-Food-Beverage-8B-Instruct"
model = AutoModelForCausalLM.from_pretrained(model_name, device_map="auto")
tokenizer = AutoTokenizer.from_pretrained(model_name)
system_prompt = '่ฏทๆ นๆฎ็จๆทๆไพ็่ฅ้้ๆฑใ้ๅๅๅ
ถไปไฟกๆฏๅไธ็ฏ้ฃๅ้ฅฎๆ่กไธ็่ฅ้ๆจๆใ'
user_prompt = """่ฅ้้ๆฑ๏ผๅคๆฅๆธ
ๅ๏ผๆฅๆ้ฃๅณไฝ้ช
้ๅ๏ผๆธ
ๆฐๆ ๆชฌๅฏฟๅธๅท
้ๅ็ฅ่ฏๅบ๏ผ1ใ้็จๆฐ้ฒ็ไธๆ้ฑผๅ็ๆฒนๆ๏ผๆญ้
ๆธ
็ฝๆ ๆชฌๆฑ๏ผๅฃๆๅฑๆฌกไธฐๅฏใ2ใไฝ่ๅฅๅบท๏ผ้ๅๅฅ่บซไบบๅฃซใ3ใๆฏไปฝไป
ๅซ200ๅคงๅก๏ผ่ฝปๆพไบซๅ็พๅณใ
ๅ
ณ้ฎ่ฏ๏ผๆฅๆใๅฏฟๅธใๅฅๅบท้ฅฎ้ฃใๅคๆฅ็พ้ฃ
ไธปๆจๅ็น๏ผๆธ
ๆฐๅฅๅบท
ไธปๆจๅบๆฏ๏ผๅคๆฅ่ไผ
ๆ ็ญพ๏ผ#ๆฅๆ# #ๅฏฟๅธ# #ๅฅๅบท็พ้ฃ
ๆ็ซ ็ฑปๅ๏ผ็พ้ฃๆจ่"""
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)
Bias, Risks, and Limitations
The ContaLLM models implemented safety techniques during data generation and training, but they are not deployed automatically with in-the-loop filtering of responses like ChatGPT during inference, so the model can produce problematic outputs (especially when prompted to do so). It is also unknown what the size and composition of the corpus was used to train the base Llama 3.1 models, however it is likely to have included a mix of Web data and technical sources like books and code. The use of the models is at your own risk. You may need to monitor the outputs of the model and take appropriate actions such as content filtering if necessary.
License and use
All Llama 3.1 ContaAI models are released under Meta's Llama 3.1 Community License Agreement.
- Downloads last month
- 18
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="ContaAI/ContaLLM-Food-Beverage-8B-Instruct") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)