Skip to content

模型

LLMs (大型语言模型)

  • GPT系列 (GPT-3, GPT-4等)
  • BERT
  • LLaMA
  • Claude

Chat Models (对话模型)

  • ChatGPT
  • Claude Chat
  • Gemini
  • 文心一言
  • 通义千问
python
from langchain_ollama import ChatOllama
llm = ChatOllama(
    model = "qwen2:1.5b",
    temperature = 0
)

from langchain.prompts.chat import (
    ChatPromptTemplate,
    SystemMessagePromptTemplate,
    HumanMessagePromptTemplate,
)

template = "你是一个翻译助理 ,请将用户输入的内容由{input_language}直接翻译为{output_language}."
system_message_prompt = SystemMessagePromptTemplate.from_template(template)
human_template = "{text}"
human_message_prompt = HumanMessagePromptTemplate.from_template(human_template)

chat_prompt = ChatPromptTemplate.from_messages([system_message_prompt, human_message_prompt])

res = llm.invoke(chat_prompt.format_prompt(input_language="英语", output_language="中文",
                 text="I'm a student from China. ").to_messages())

print(res.content)

输出

json
我是一名来自中国的学生。

Text Embedding Models (文本嵌入模型)

  • OpenAI Ada
  • Cohere Embed
  • Sentence Transformers
  • Word2Vec
  • GloVe

每种模型类型都有其特定的应用场景和优势:

  • LLMs适用于文本生成、理解和处理
  • Chat Models专门优化用于人机对话交互
  • Text Embedding Models用于将文本转换为向量表示,便于相似度计算和语义检索

Chat