Huggingface模型地址 | 魔搭社区模型地址 | Github地址
简介
cvx-coder 增强了大模型CVX 代码能力和QA能力。它是phi-3在CVX文档, 合成代码, 论坛对话数据上的微调版本。
开始
先从魔搭下载模型:
git clone https://www.modelscope.cn/tommy1235/cvx-coder.git
然后运行下面示例代码
from transformers import AutoModelForCausalLM, AutoTokenizer, pipeline
m_path="你的路径/cvx-coder"
model = AutoModelForCausalLM.from_pretrained(
m_path,
device_map="cuda",
torch_dtype="auto",
trust_remote_code=True,
)
tokenizer = AutoTokenizer.from_pretrained(m_path)
pipe = pipeline(
"text-generation",
model=model,
tokenizer=tokenizer,
)
generation_args = {
"max_new_tokens": 2000,
"return_full_text": False,
"temperature": 0,
"do_sample": False,
}
content='''my problem is not convex, can i use cvx? if not, what should i do, be specific.'''
messages = [
{"role": "user", "content": content},
]
output = pipe(messages, **generation_args)
print(output[0]['generated_text'])