Comments (2)
Hope this would work for you:
context = """意大利大道(Boulevard des Italiens)是巴黎东西走向连贯的四条“grands boulevards”之一,自西向东包括马德莱娜大道、卡布辛大道(Boulevard des Capucines)、意大利大道和蒙马特大道。它得名于法国革命前不久的1783年建于此处的意大利剧院(现在的巴黎喜剧院)。此前使用过的名称有boulevard Neuf、boulevard du Dépôt、boulevard de la Chaussée d'Antin、boulevard Cerutti(法国革命期间)、根特大道(boulevard de Gand,1815 - 1828年)。1795年后,许多流亡者在督政府时期从国外返回法国,聚集于此,使它获得“小科布伦茨”的绰号。第二次波旁复辟时称为根特大道(boulevard de Gand),以纪念路易十八在百日王朝时流亡到根特。在整个19世纪,这条大道是一巴黎精英们的聚会场所(这一角色一直持续到第一次世界大战),当时也是巴黎咖啡馆和杜昂咖啡馆(Tortoni,布宜诺斯艾利斯的那座也得名于巴黎的这座)的时代。奥斯曼大道在1920年代完成后,这些建筑消失了,被代之以其他建筑物,特别是财政方面的-法国巴黎银行总部,约瑟夫·马拉斯特设计。"""
questions = [
"意大利大道属于哪个国家?",
"“小科布伦茨”这一绰号有什么由来?",
"意大利大道上现在有多少家咖啡店?",
]
from transformers import AutoTokenizer, AutoModelForCausalLM
tokenizer = AutoTokenizer.from_pretrained("internlm/internlm-chat-7b", trust_remote_code=True)
model = AutoModelForCausalLM.from_pretrained("internlm/internlm-chat-7b", trust_remote_code=True).cuda()
model = model.eval()
prompt_template = """假设你是一个智能助理,你希望能够回答用户的问题,用户的问题可能是任意的,但是你只能使用以下信息来回答用户的问题:
{context}
你的回答应该是一个完整的句子,你需要首先正面回答用户的问题,同时提供尽可能充分的细节,你需要表现地足够热情、友善。如果无法从中得到答案,请说 “抱歉,根据已知信息无法回答该问题”,不允许在答案中添加编造成分,答案请使用中文。
以下是用户的问题:请问{question}"""
for question in questions:
prompt = prompt_template.format(context=context, question=question)
response, history = model.chat(tokenizer, prompt, history=[])
print(question + '\n' + response)
意大利大道属于哪个国家?
意大利大道是巴黎东西走向连贯的四条“grands boulevards”之一,位于法国。
“小科布伦茨”这一绰号有什么由来?
1795年后,许多流亡者在督政府时期从国外返回法国,聚集于此,使它获得“小科布伦茨”的绰号。
意大利大道上现在有多少家咖啡店?
抱歉,根据已知信息无法回答该问题
from internlm.
Feel free to re-open this issue if you have more questions, also more useful prompts are welcomed.
from internlm.
Related Issues (20)
- 请问是否支持200k上文的微调,需要什么样的配置?[QA] HOT 2
- [QA] InternLM 2 对文字种类的识别, 生成能力以及微调相关问题 HOT 6
- [Bug] InternLM2 int4 出现重复说话、重复前置内容(system prompt)现象 HOT 9
- [Bug] When loading a model by using transformers and using stream chat, it seems no whitespace character in English response. HOT 1
- [QA] Number of training tokens for Internlm2 1.8B, 7B, and 20B? HOT 3
- [QA] 请问是否会开源PPO的训练code和reward model? HOT 1
- [Feature] 是否已经支持tensorrt-llm或者计划支持? HOT 2
- [Bug] Special tokens are still mismatched. HOT 2
- [Bug] internlm2-chat-20b huggingface下载503报错,模型不存在
- 一人血书求讲解怎么来洗数据! HOT 5
- 万人血书 InternLM2-4B ❗❕❗❕❗
- [QA] Can internlm2 be supported in fastchat? HOT 6
- [Bug] failing everytime and getting CUDA out of memory HOT 6
- [Bug] internlm2_chat_1.8b 模型不支持多轮对话 HOT 2
- [QA] 使用InternLM微调qa机器人,如何让它从训练资料中选择答案,而不是自己生成? HOT 2
- [Feature] convert2llama.py HOT 1
- [Bug] safetensors_rust.SafetensorError: Error while deserializing header: HeaderTooLarge HOT 3
- [QA] Question about phase 2 long context pretraining batch size HOT 3
- [QA] 请问如何在昇腾910上进行模型微调? HOT 3
- [Feature] 一个把internLM2 LoRA部分转换成llama风格的脚本
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from internlm.