Text Generation
Transformers
Safetensors
qwen2
conversational
text-generation-inference
4-bit precision
awq
Instructions to use svjack/DPO_Genshin_Impact_Qwen_1_5_Plot_Engine_Step_Json_Short_AWQ with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use svjack/DPO_Genshin_Impact_Qwen_1_5_Plot_Engine_Step_Json_Short_AWQ with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("text-generation", model="svjack/DPO_Genshin_Impact_Qwen_1_5_Plot_Engine_Step_Json_Short_AWQ") messages = [ {"role": "user", "content": "Who are you?"}, ] pipe(messages)# Load model directly from transformers import AutoTokenizer, AutoModelForCausalLM tokenizer = AutoTokenizer.from_pretrained("svjack/DPO_Genshin_Impact_Qwen_1_5_Plot_Engine_Step_Json_Short_AWQ") model = AutoModelForCausalLM.from_pretrained("svjack/DPO_Genshin_Impact_Qwen_1_5_Plot_Engine_Step_Json_Short_AWQ") 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=40) print(tokenizer.decode(outputs[0][inputs["input_ids"].shape[-1]:])) - Notebooks
- Google Colab
- Kaggle
- Local Apps Settings
- vLLM
How to use svjack/DPO_Genshin_Impact_Qwen_1_5_Plot_Engine_Step_Json_Short_AWQ with vLLM:
Install from pip and serve model
# Install vLLM from pip: pip install vllm # Start the vLLM server: vllm serve "svjack/DPO_Genshin_Impact_Qwen_1_5_Plot_Engine_Step_Json_Short_AWQ" # Call the server using curl (OpenAI-compatible API): curl -X POST "http://localhost:8000/v1/chat/completions" \ -H "Content-Type: application/json" \ --data '{ "model": "svjack/DPO_Genshin_Impact_Qwen_1_5_Plot_Engine_Step_Json_Short_AWQ", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }'Use Docker
docker model run hf.co/svjack/DPO_Genshin_Impact_Qwen_1_5_Plot_Engine_Step_Json_Short_AWQ
- SGLang
How to use svjack/DPO_Genshin_Impact_Qwen_1_5_Plot_Engine_Step_Json_Short_AWQ 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 "svjack/DPO_Genshin_Impact_Qwen_1_5_Plot_Engine_Step_Json_Short_AWQ" \ --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": "svjack/DPO_Genshin_Impact_Qwen_1_5_Plot_Engine_Step_Json_Short_AWQ", "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 "svjack/DPO_Genshin_Impact_Qwen_1_5_Plot_Engine_Step_Json_Short_AWQ" \ --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": "svjack/DPO_Genshin_Impact_Qwen_1_5_Plot_Engine_Step_Json_Short_AWQ", "messages": [ { "role": "user", "content": "What is the capital of France?" } ] }' - Docker Model Runner
How to use svjack/DPO_Genshin_Impact_Qwen_1_5_Plot_Engine_Step_Json_Short_AWQ with Docker Model Runner:
docker model run hf.co/svjack/DPO_Genshin_Impact_Qwen_1_5_Plot_Engine_Step_Json_Short_AWQ
YAML Metadata Warning:empty or missing yaml metadata in repo card
Check out the documentation for more information.
🤭 Please refer to https://github.com/svjack/Genshin-Impact-Character-Chat to get more info
Run vLLM Server
python -m vllm.entrypoints.openai.api_server --model svjack/DPO_Genshin_Impact_Qwen_1_5_Plot_Engine_Step_Json_Short_AWQ --dtype auto \
--api-key token-abc123 --quantization awq --max-model-len 3000 --gpu-memory-utilization 0.9
Run Client
- Step 1: Generate a story Backgroud In Genshin Impact
from openai import OpenAI
from IPython.display import clear_output
# Set OpenAI's API key and API base to use vLLM's API server.
openai_api_key = "token-abc123"
openai_api_base = "http://localhost:8000/v1"
# Create an OpenAI client to interact with the API server
client = OpenAI(
api_key=openai_api_key,
base_url=openai_api_base,
)
stream = client.chat.completions.create(
model="svjack/DPO_Genshin_Impact_Qwen_1_5_Plot_Engine_Step_Json_Short_AWQ", # Model name to use
messages=[
{
"role" :"system",
"content": ""
},
{
"role": "user",
"content": '''
故事标题:归乡
故事背景:在须弥城门口,派蒙与纳西妲偶遇并帮助一只昏迷的元素生命找寻家园。过程中揭示了这只生物并非普通的蕈兽,而是元素生物,并且它们曾受到过‘末日’的影响,家园被侵蚀。纳西妲回忆起晶体里的力量可能与一个预言有关,为了拯救它们的家园,她必须解决‘禁忌知识’问题,但这个过程对她自身也会产生干扰。
参与角色:派蒙、纳西妲、浮游水蕈兽、旅行者
'''
},
], # Chat history
temperature=0.01, # Temperature for text generation
stream=True, # Stream response
)
# Read and return generated text from response stream
partial_message = ""
for chunk in stream:
clear_output(wait = True)
partial_message += (chunk.choices[0].delta.content or "")
print(partial_message)
Output
{'参与者1': '派蒙', '参与者2': '纳西妲', '当前故事背景': '两人在须弥城门口交谈,纳西妲提到她刚从外面回来,而派蒙则表示自己是来见纳西妲的。纳西妲提到她有事要办,但随后被一只元素生命吸引,决定帮助它寻找家园。'}
def openai_predict(messages, temperature = 0.01):
stream = client.chat.completions.create(
model="svjack/DPO_Genshin_Impact_Qwen_1_5_Plot_Engine_Step_Json_Short_AWQ", # Model name to use
messages=messages, # Chat history
temperature=temperature, # Temperature for text generation
stream=True, # Stream response
)
# Read and return generated text from response stream
partial_message = ""
for chunk in stream:
clear_output(wait = True)
partial_message += (chunk.choices[0].delta.content or "")
print(partial_message)
return partial_message
from rapidfuzz import fuzz
from IPython.display import clear_output
def run_step_infer_times(x, times = 5, temperature = 0.01,
repetition_penalty = 1.0,
sim_val = 70
):
req = []
for _ in range(times):
clear_output(wait = True)
out = openai_predict([
{
"role": "system",
"content": ""
},
{
"role": "user",
"content": x
},
],
#repetition_penalty = repetition_penalty,
temperature = temperature,
#max_new_tokens = 2070,
#max_input_length = 6000,
)
if req:
val = max(map(lambda x: fuzz.ratio(x, out), req))
#print(val)
#print(req)
if val < sim_val:
req.append(out.strip())
x = x.strip() + "\n" + out.strip()
else:
req.append(out.strip())
x = x.strip() + "\n" + out.strip()
return req
out_l = run_step_infer_times(
'''
故事标题:归乡
故事背景:在须弥城门口,派蒙与纳西妲偶遇并帮助一只昏迷的元素生命找寻家园。过程中揭示了这只生物并非普通的蕈兽,而是元素生物,并且它们曾受到过‘末日’的影响,家园被侵蚀。纳西妲回忆起晶体里的力量可能与一个预言有关,为了拯救它们的家园,她必须解决‘禁忌知识’问题,但这个过程对她自身也会产生干扰。
参与角色:派蒙、纳西妲、浮游水蕈兽、旅行者
''',
temperature=0.1,
repetition_penalty = 1.0,
times = 5
)
clear_output(wait = True)
print("\n".join(out_l))
Output
{'参与者1': '派蒙', '参与者2': '纳西妲', '当前故事背景': '两人在须弥城门口相遇,纳西妲提到她刚从外面回来,而派蒙则表示自己是来见纳西妲的。纳西妲提到她有事要办,但随后被一只元素生命吸引,决定帮助它寻找家园。'}
{'参与者1': '派蒙', '参与者2': '浮游水蕈兽', '当前故事背景': '派蒙询问浮游水蕈兽为何会出现在这里,得知它因力量耗尽而昏迷。纳西妲解释它曾是‘禁忌知识’的守护者,但力量被污染,家园被侵蚀。'}
{'参与者1': '纳西妲', '参与者2': '浮游水蕈兽', '当前故事背景': '纳西妲回忆起晶体中的力量与一个预言有关,她意识到这可能是拯救浮游水蕈兽家园的关键。她提出要解决‘禁忌知识’问题,但担心这会对她自身产生影响。'}
{'参与者1': '派蒙', '参与者2': '纳西妲', '当前故事背景': '派蒙对纳西妲突然的行动感到惊讶,纳西妲解释自己有事要办,并请求派蒙帮忙。'}
{'参与者1': '浮游水蕈兽', '参与者2': '纳西妲', '当前故事背景': '浮游水蕈兽在昏迷前透露了它曾是‘禁忌知识’的守护者,家园被一个强大存在摧毁。'}
- Downloads last month
- 2