SeanJIE250/llama2_law
Viewer • Updated • 21.5k • 5 • 1
How to use SeanJIE250/llama2_chatbot_law with Transformers:
# Use a pipeline as a high-level helper
from transformers import pipeline
pipe = pipeline("text-generation", model="SeanJIE250/llama2_chatbot_law") # Load model directly
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("SeanJIE250/llama2_chatbot_law")
model = AutoModelForCausalLM.from_pretrained("SeanJIE250/llama2_chatbot_law")How to use SeanJIE250/llama2_chatbot_law with vLLM:
# Install vLLM from pip:
pip install vllm
# Start the vLLM server:
vllm serve "SeanJIE250/llama2_chatbot_law"
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:8000/v1/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "SeanJIE250/llama2_chatbot_law",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'docker model run hf.co/SeanJIE250/llama2_chatbot_law
How to use SeanJIE250/llama2_chatbot_law with SGLang:
# Install SGLang from pip:
pip install sglang
# Start the SGLang server:
python3 -m sglang.launch_server \
--model-path "SeanJIE250/llama2_chatbot_law" \
--host 0.0.0.0 \
--port 30000
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:30000/v1/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "SeanJIE250/llama2_chatbot_law",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'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 "SeanJIE250/llama2_chatbot_law" \
--host 0.0.0.0 \
--port 30000
# Call the server using curl (OpenAI-compatible API):
curl -X POST "http://localhost:30000/v1/completions" \
-H "Content-Type: application/json" \
--data '{
"model": "SeanJIE250/llama2_chatbot_law",
"prompt": "Once upon a time,",
"max_tokens": 512,
"temperature": 0.5
}'How to use SeanJIE250/llama2_chatbot_law with Docker Model Runner:
docker model run hf.co/SeanJIE250/llama2_chatbot_law
Email:zhengjie1sun@gmail.com
Give me some red stars ♥️ if u like this model! It's the model focused on Law field, honestly,doing bad as a daily chatbot however,start to know Mandarin and can handle the case study in details.
老玩家点点红星♥️!中文法律对话机器人,具体案件审理较为不错。
First at first , implementing this command needs transformer library ,you can do the download directly.Hope u well!
from transformers import AutoModelForCausalLM, AutoTokenizer
model_path = "SeanJIE250/chatbot_LAW"
tokenizer = AutoTokenizer.from_pretrained(model_path)
model = AutoModelForCausalLM.from_pretrained(
model_path,
device_map="auto",
torch_dtype='auto'
).eval()
# Prompt content: "hi"
messages = [
{"role": "user", "content": "杀了人在中国判多少年?"}
]
input_ids = tokenizer.apply_chat_template(conversation=messages, tokenize=True, add_generation_prompt=True, return_tensors='pt')
outputs = model.generate(input_ids.to('cuda'),max_new_tokens=200)//you can adjust the max_new_tokens as you want.
response = tokenizer.decode(outputs[0][input_ids.shape[1]:], skip_special_tokens=False)
print(response)
messages = [
{"role": "user", "content": "How to split the property if I divorced with my handsband?"}
]
input_ids = tokenizer.apply_chat_template(conversation=messages, tokenize=True, add_generation_prompt=True, return_tensors='pt')
outputs = model.generate(input_ids.to('cuda'),max_new_tokens=200)//you can adjust the max_new_tokens as you want.
response = tokenizer.decode(outputs[0][input_ids.shape[1]:], skip_special_tokens=False)
print(response)