Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mistaken character of streaming output in jupyter notebook #190

Open
KaedinLian opened this issue Jun 5, 2023 · 1 comment
Open

Mistaken character of streaming output in jupyter notebook #190

KaedinLian opened this issue Jun 5, 2023 · 1 comment

Comments

@KaedinLian
Copy link

The bug
get .��� character after running guidance writen by chinese in jupyter nokebook. And in normal .py file, it works fine.

To Reproduce
Give a full working code snippet that can be pasted into a notebook cell or python file. Make sure to include the LLM load step so we know which model you are using.

# put your code snippet here
import os
import guidance
import guidance

guidance.llm = guidance.llms.transformers.Vicuna("vicuna-13b", device_map="auto", load_in_8bit=True, acceleration=False)
strategy = [
    {"strategy":"直接指导", "explaination": "提供建议、指令或指示,指引寻求帮助者应该怎样做才能改变"},
    {"strategy":"其他", "explaination": "上面六种策略之外的内容"},
    ]
new_question = "人生中的坎坷路,有时把情绪带回家,这情况怎么治?"
zero_program = guidance("""你是一名经验丰富的执证心理咨询师。在咨询时你会用到以下策略。
{{#each strategy}}{{this.strategy}}: {{this.explaination}}
{{/each~}}
下面是咨询过程的摘要,请还原成对话。
{{question}}
{{~#geneach 'conversation' num_iterations=2}}
用户:
{{~gen 'this.user' temperature=0.7 max_tokens=100 stop='\\n'}}
心理咨询师:
{{~gen 'this.ai' temperature=0.7 max_tokens=100 stop='\\n'}}
{{/geneach}}
""")
executed_program = zero_program(
    strategy=strategy,
    question=new_question,
    new_question=new_question
)
# one of output
#用户: 我���得有时候我会���到������过,不知道该���么���。
#心理咨询师: 我明白���的������。有时候我们会���到������和不确定,不知道该���么���。���是,我想告������,���不是������的。这种情������常���,���多人都会���

System info (please complete the following information):

  • OS (e.g. Ubuntu, Windows 11, Mac OS, etc.): Ubuntu
  • Guidance Version (guidance.__version__): 0.0.57

Imformation
I seach on the web, someone said " It caused by decoding GBK encoded chinese by uft8".
Is there any tips for which code or how should I change?
Appreciate.

@KaedinLian
Copy link
Author

I now found same issue in .py file when setting stream=True

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant