Git Product home page Git Product logo

Comments (2)

Leymore avatar Leymore commented on May 18, 2024 6

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.

tonysy avatar tonysy commented on May 18, 2024

Feel free to re-open this issue if you have more questions, also more useful prompts are welcomed.

from internlm.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.