qwen.cpp icon indicating copy to clipboard operation
qwen.cpp copied to clipboard

How to use the python binding?

Open sunxichen opened this issue 1 year ago • 9 comments

I successfully installed it from source, but I don't know how to use the chat and stream_chat interfaces, or how to load the model, etc. Are there any documents that I can refer to?

sunxichen avatar Sep 27 '23 09:09 sunxichen

how do you convert the model。

xwdreamer avatar Sep 27 '23 09:09 xwdreamer

how do you convert the model。

Just follow the instruction in README. I converted the model in Intel Mac, not M1, and there is no error. I'm using transformers==4.33.2, maybe check your transformers package version?

sunxichen avatar Sep 27 '23 10:09 sunxichen

Now only supports tiktoken_cpp python bindings. I will release more python bindings within this week. Stay tuned.

simonJJJ avatar Oct 03 '23 17:10 simonJJJ

Mark, I need Python bindings too.

quan2005 avatar Oct 10 '23 02:10 quan2005

Python bindings are available now.

simonJJJ avatar Oct 19 '23 09:10 simonJJJ

Python bindings are available now.

怎么使用,没有在文档里面看到,目前只有tiktoken_cpp python bindings

AppleJunJiang avatar Oct 23 '23 05:10 AppleJunJiang

You can use below codes in python

from qwen_cpp import Pipeline                 
pipeline = Pipeline("/path_to_models/qwen7b-ggml.bin", "/path_to_tiktoken/Qwen-7B-Chat/qwen.tiktoken")

result1 = pipeline.chat(["Hello"])
print(result1)
result2 = pipeline.chat(["Hello"],stream=True)
for item in result2:
  print(item)

yuebo avatar Nov 02 '23 05:11 yuebo

Seem python-bind did not support ”system”! Anyway to support it? it should be easy to change the tokenizer to support

cailuyu avatar Dec 22 '23 06:12 cailuyu

You can use below codes in python

from qwen_cpp import Pipeline                 
pipeline = Pipeline("/path_to_models/qwen7b-ggml.bin", "/path_to_tiktoken/Qwen-7B-Chat/qwen.tiktoken")

result1 = pipeline.chat(["Hello"])
print(result1)
result2 = pipeline.chat(["Hello"],stream=True)
for item in result2:
  print(item)

@yuebo 请问可以指定只在cpu上运行吗?

zzzcccxx avatar Feb 01 '24 07:02 zzzcccxx