diff --git a/pages/models/_meta.zh.json b/pages/models/_meta.zh.json index c0c88ac73..945ad1e5a 100644 --- a/pages/models/_meta.zh.json +++ b/pages/models/_meta.zh.json @@ -1,18 +1,23 @@ { - "flan": "Flan", "chatgpt": "ChatGPT", - "llama": "LLaMA", "gpt-4": "GPT-4", - "mistral-7b": "Mistral 7B", + "claude-3": "Claude 3", + "code-llama": "Code Llama", + "flan": "Flan", "gemini": "Gemini", "gemini-advanced": "Gemini Advanced", "gemini-pro": "Gemini 1.5 Pro", - "phi-2": "Phi-2", + "gemma": "Gemma", + "grok-1": "Grok-1", + "llama": "LLaMA", + "llama-3": "Llama 3", + "mistral-7b": "Mistral 7B", + "mistral-large": "Mistral Large", "mixtral": "Mixtral", - "code-llama": "Code Llama", - "olmo": "OLMo", + "mixtral-8x22b": "Mixtral 8x22B", + "olmo": "OLMo", + "phi-2": "Phi-2", "sora": "Sora", - "collection": "Model Collection" + "collection": "LLM Collection" } - \ No newline at end of file diff --git a/pages/models/claude-3.zh.mdx b/pages/models/claude-3.zh.mdx new file mode 100644 index 000000000..3f0189e3c --- /dev/null +++ b/pages/models/claude-3.zh.mdx @@ -0,0 +1,27 @@ +# Claude 3 + +Anthropic announces Claude 3, their new family of models that include Claude 3 Haiku, Claude 3 Sonnet, and Claude 3 Opus. + +Claude 3 Opus (the strongest model) is reported to outperform GPT-4 and all other models on common benchmarks like MMLU and HumanEval. + +## Results and Capabilities + +Claude 3 capabilities include advanced reasoning, basic mathematics, analysis, data extraction, forecasting, content creation, code generation, and converting in non-English languages like Spanish, Japanese, and French. The table below demonstrates how Claude 3 compares with other models on several benchmarks with Claude 3 Opus outperforming all the mentioned models: + +!["Claude 3 Benchmarks"](../../img/claude/claude-benchmark.png) + +Claude 3 Haiku is the fastest and most cost-effective model of the series. Claude 3 Sonnet is 2x faster than previous iterations of Claude and Opus is as fast as Claude 2.1 with more superior capabilities. + + +The Claude 3 models offer support for 200K context windows but can be extended to 1M tokens to select customers. Claude 3 Opus achieved near-perfect recall on the Needle In A Haystack (NIAH) evaluation which measures the model's ability to recall information in a large corpus and effectively process long context prompts. + +The models also have strong vision capabilities for processing formats like photos, charts, and graphs. + +!["Claude 3 Vision Capabilities"](../../img/claude/claude-vision.png) + +Anthropic also claim that these models have a more nuanced understanding of requests and make fewer refusals. Opus also shows significant improvements in factual question answering in open-ended questions while reducing incorrect answers or hallucinations. Claude 3 models are also better than the Claude 2 models at producing structured outputs like JSON objects. + +## References + +- [Claude 3 Haiku, Claude 3 Sonnet, and Claude 3 Opus](https://www.anthropic.com/news/claude-3-family) +- [The Claude 3 Model Family: Opus, Sonnet, Haiku](https://www-cdn.anthropic.com/de8ba9b01c9ab7cbabf5c33b80b7bbc618857627/Model_Card_Claude_3.pdf) \ No newline at end of file diff --git a/pages/models/gemma.zh.mdx b/pages/models/gemma.zh.mdx new file mode 100644 index 000000000..0b60541bb --- /dev/null +++ b/pages/models/gemma.zh.mdx @@ -0,0 +1,174 @@ +# Gemma + +Google DeepMind 发布了 Gemma,这是一个系列的开源语言模型,灵感来自创建 Gemini 的研究和技术。Gemma 模型发布包括 2B(训练于 2T tokens)和 7B(训练于 6T tokens)模型,包括基础和指令微调的检查点。这些模型在 8192 tokens 的上下文长度上训练,且在多个基准测试中通常优于 Llama 2 7B 和 Mistral 7B 模型。 + +Gemma 模型架构基于 Transformer 解码器,并进行了改进,包括 [多查询注意力](http://arxiv.org/abs/1911.02150)(用于 2B 模型)、多头注意力(用于 7B 模型)、[RoPE 嵌入](https://arxiv.org/abs/2104.09864)、[GeGLU 激活](https://arxiv.org/abs/2002.05202) 和 [标准化位置](http://arxiv.org/abs/1910.07467)。 + +根据 [技术报告](https://storage.googleapis.com/deepmind-media/gemma/gemma-report.pdf),Gemma 2B 和 7B 分别在 2T 和 6T tokens 上进行训练,主要由网页文档、数学和代码组成。与 Gemini 不同,这些模型没有明确训练来支持多语言或多模态功能。词汇量为 256K tokens,使用 Gemini 的 SentencePiece 分词的一个子集,保留分词中的空格,分割数字,并依赖字节级编码处理未知的 tokens。 + +指令微调模型通过在混合文本中进行监督微调,包括合成的和人工生成的提示 - 响应对,并通过人类反馈的强化学习(RLHF)进行微调,奖励模型基于标记的偏好数据,策略基于一组高质量提示。注意所有使用的数据集仅为英文。如下面的表格所示,指令微调模型还使用特定的格式控制 tokens 来表示对话中的角色和轮次。 + +!["Gemma 控制 tokens"](../../img/gemma/control-tokens.png) + +## 结果 + +如下图所示,Gemma 7B 模型在数学、科学和代码相关任务上表现出强劲性能。分数对应于按能力分组的学术基准评估的平均分数。 + +!["Gemma 能力"](../../img/gemma/capabilities.png) + +Gemma 7B 在各种学术基准测试中优于 Llama 2 7B 和 Mistral 7B,在 HumanEval、GSM8K、MATH 和 AGIEval 上表现尤其突出,并在推理、对话、数学和代码方面有所提升。 + +!["Gemma 基准测试"](../../img/gemma/benchmarks.png) + +Gemma 7B 指令微调模型在人类评估的安全性和指令遵循上也优于 Mistral-7B v0.2 Instruct 模型。 + +!["Gemma 安全性"](../../img/gemma/safety.png) + +Gemma 还在多个安全性学术基准测试中进行了评估,并与 Mistral 进行了比较。技术报告还提到了使用去偏见技术和红队测试来潜在地减轻与大语言模型(LLMs)相关的常见风险。你可以在 [模型卡](https://ai.google.dev/gemma/docs/model_card) 和 [负责任生成 AI 工具包](https://ai.google.dev/responsible) 中找到有关如何负责任地开发 Gemma 的更多信息。 + +!["Gemma 安全性"](../../img/gemma/safety-2.png) + +## Gemma 7B 提示格式 + +Gemma 基础模型不使用任何特定的提示格式,但可以通过零样本 / 少样本提示来执行任务。Gemma Instruct 模型使用以下格式: + +``` +user +Generate a Python function that multiplies two numbers +model +``` + +以下是 Gemma 中可用的相关格式控制 tokens 表: + +| Context | Relevant Token | +|---------------------------------|--------------------| +| User turn | `user` | +| Model turn | `model` | +| Start of conversation turn | `` | +| End of conversation turn | `` | + +你还可以在多轮用户提示的上下文中使用特殊控制 tokens,如下所示: + +```markdown +user +What is a good place for travel in the US? +model +California. +user +What can I do in California? +model +``` + +## 如何提示 Gemma 7B + +有效提示 Gemma 7B 需要能够正确使用提示模板。在以下示例中,我们将介绍一些示例,展示如何有效使用 Gemma 7B Instruct 的提示模板来完成各种任务。 + +### 零样本提示 +与任何模型一样,你可以通过如下简单提示利用 Gemma 的零样本能力: + +```markdown +user +Explain why the sky is blue +model +``` + +### 零样本提示与系统提示 +添加系统角色或系统提示有助于更好地引导 LLMs。虽然 Gemma 中没有明确的系统角色,你可以如下在提示中添加额外说明: + +```markdown +user +Answer the following question in a concise and informative manner: + +Explain why the sky is blue +model +``` + +在上述示例中,我们添加了 “Answer the following question in a concise and informative manner:” 作为额外说明或系统提示,以更好地引导模型。 + +### 角色扮演 +我们还可以测试 Gemma 的角色扮演能力,这是不仅个性化模型响应的有用功能,还可以构建更复杂的特定领域 [LLM 代理](https://www.promptingguide.ai/research/llm-agents)。 + +提示: +``` +user +You are a helpful 2nd-grade teacher. Help a 2nd grader to answer questions in a short and clear manner. + +Explain why the sky is blue +model +``` + +模型响应: +``` +Sure, here is an explanation for why the sky is blue: + +The sky appears blue because of a phenomenon called Rayleigh Scattering. + +Here's the science behind it: + +Sunlight is made up of different colors of light, like red, green, blue, and violet. +When sunlight hits the Earth's atmosphere, the different colors of light scatter in different directions. +Blue light scatters more easily than other colors because it has shorter wavelengths. +The scattered blue light travels in all directions, including towards your eyes. +That's why we see the sky as blue. +It's important to note that this explanation is simplified and does not account for all scientific details. However, it gives you a good understanding of the basic science behind why the sky appears blue. +``` + +注意我们没有检查响应的准确性或其是否适合 2 年级学生。然而,你可以将上述响应与后续链式思维提示获得的响应进行比较。 + +### 推理 +你可以通过使用 [零样本链式思维提示](https://www.promptingguide.ai/techniques/cot#zero-shot-cot-prompting) 来引出 Gemma 的推理能力,如下所示: + +提示: +```markdown +user +Think and write your step-by-step reasoning before responding. + +Explain why the sky is blue. +model +``` + +模型响应(为简洁起见截断): +``` +Step 1: Scattering of Light + +The sky appears blue due to the phenomenon of scattering of light. When sunlight hits the Earth's atmosphere, it interacts with the particles of air, primarily nitrogen and oxygen molecules. + +Step 2: Rayleigh Scattering + +Rayleigh scattering is the specific scattering mechanism that occurs when light interacts with particles much smaller than the wavelength of light. In this process, shorter wavelengths (blue light) are scattered more effectively than longer wavelengths (red light). + +Step 3: Blue Scattered Light Travels in All Directions + +... + +Conclusion + +The sky appears blue due to the scattering of light, specifically Rayleigh scattering. Shorter wavelengths of light are scattered more effectively, and this scattered light travels in all directions, with the scattered light that travels opposite to the sun's rays being most visible to our eyes. +``` + +需要注意的是,Gemma 模型可以自动输出 markdown 格式。为了演示和简化,我们对文本格式进行了一些编辑,但内容完全是模型的响应。注意我们也没有评估响应的准确性或模型是否出现幻觉。 + +## 资源和集成 + +以下是 Gemma 发布的一些资源和集成: + +- [Colab](https://ai.google.dev/gemma/docs/get_started) 和 [Kaggle](https://www.kaggle.com/models/google/gemma/code) 笔记本 +- [Hugging Face 模型](https://huggingface.co/collections/google/gemma-release-65d5efbccdbb8c4202ec078b) +- [MaxText](https://github.com/google/maxtext) +- [NVIDIA NeMo](https://github.com/NVIDIA/GenerativeAIExamples/tree/main/models/Gemma) +- [TensorRT-LLM](https://developer.nvidia.com/blog/nvidia-tensorrt-llm-revs + +-up-inference-for-google-gemma/) +- Gemma 7B 可在 [NVIDIA AI Playground](https://catalog.ngc.nvidia.com/orgs/nvidia/teams/ai-foundation/models/gemma-7b) 中获取 + +根据官方 [博客发布](https://blog.google/technology/developers/gemma-open-models/),[使用条款](https://www.kaggle.com/models/google/gemma/license/consent) 允许所有组织负责任地进行商业使用和分发,无论其规模如何。 + +## 参考文献 + +- [Gemma: Introducing new state-of-the-art open models](https://blog.google/technology/developers/gemma-open-models/) +- [Gemma: Open Models Based on Gemini Research and Technology](https://storage.googleapis.com/deepmind-media/gemma/gemma-report.pdf) +- [Responsible Generative AI Toolkit](https://ai.google.dev/responsible) +- [Fast Transformer Decoding: One Write-Head is All You Need](https://arxiv.org/abs/1911.02150) +- [Roformer: Enhanced transformer with rotary position embedding](https://arxiv.org/abs/2104.09864) +- [GLU variants improve transformer](https://arxiv.org/abs/2002.05202) +- [Root mean square layer normalization](http://arxiv.org/abs/1910.07467) \ No newline at end of file diff --git a/pages/models/grok-1.zh.mdx b/pages/models/grok-1.zh.mdx new file mode 100644 index 000000000..d88ce5425 --- /dev/null +++ b/pages/models/grok-1.zh.mdx @@ -0,0 +1,28 @@ +# Grok-1 + +Grok-1 是一个包含 3140 亿参数的混合专家 (MoE) 大型语言模型 (LLM),包括基础模型权重和网络架构的开放发布。 + +Grok-1 由 xAI 训练,包含的 MoE 模型在推理时会激活给定令牌的 25% 权重。Grok-1 的预训练截止日期为 2023 年 10 月。 + +如 [官方公告](https://x.ai/blog/grok-os) 中所述,Grok-1 是预训练阶段的原始基础模型检查点,这意味着它尚未针对任何特定应用进行微调,如对话代理。 + +该模型已根据 Apache 2.0 许可证 [发布](https://github.com/xai-org/grok-1)。 + +## 结果和能力 + +根据最初的[公告](https://x.ai/blog/grok),Grok-1 在推理和编码任务方面表现出强大的能力。最新公开的结果显示,Grok-1 在 HumanEval 编码任务中达到 63.2%,在 MMLU 中达到 73%。它通常优于 ChatGPT-3.5 和 Inflection-1,但仍落后于改进模型如 GPT-4。 + +![Grok-1 Benchmark Results](../../img/grok/grok-reasoning.png) + +据报道,Grok-1 在匈牙利高中数学期末考试中得分为 C (59%),而 GPT-4 得分为 B (68%)。 + +![Grok-1 Benchmark Results](../../img/grok/grok-math.png) + +在此查看模型:https://github.com/xai-org/grok-1 + +由于 Grok-1 的规模(3140 亿参数),xAI 建议使用多 GPU 机器来测试该模型。 + +## 参考文献 + +- [Grok-1 的开放发布](https://x.ai/blog/grok-os) +- [宣布 Grok](https://x.ai/blog/grok) \ No newline at end of file diff --git a/pages/models/mixtral-8x22b.zh.mdx b/pages/models/mixtral-8x22b.zh.mdx new file mode 100644 index 000000000..c31e85bff --- /dev/null +++ b/pages/models/mixtral-8x22b.zh.mdx @@ -0,0 +1,28 @@ +# Mixtral 8x22B + +Mixtral 8x22B 是 Mistral AI 发布的一个新的开源大语言模型(LLM)。Mixtral 8x22B 被描述为一个稀疏专家混合模型,具有 141B 参数,其中 39B 是活跃参数。 + +## 能力 + +Mixtral 8x22B 被训练为一个具有成本效益的模型,具有多语言理解、数学推理、代码生成、本地函数调用支持和受限输出支持等能力。该模型支持 64K tokens 的上下文窗口大小,从而在处理大文档时实现高效的信息回忆。 + +Mistral AI 声称,Mixtral 8x22B 提供了社区模型中最佳的性能与成本比,并且由于其稀疏激活特性,速度显著加快。 + +!["Mixtral 8x22B 性能"](../../img/mixtral/mixtral-8-cost.png) +* 来源: [Mistral AI 博客](https://mistral.ai/news/mixtral-8x22b/)* + +## 结果 + +根据 [官方报告的结果](https://mistral.ai/news/mixtral-8x22b/),Mixtral 8x22B(具有 39B 活跃参数)在多个推理和知识基准测试上,如 MMLU、HellaS、TriQA、NaturalQA 等,优于最先进的开源模型如 Command R + 和 Llama 2 70B。 + +!["Mixtral 8x22B 推理和知识性能"](../../img/mixtral/mixtral-8-reasoning.png) +* 来源: [Mistral AI 博客](https://mistral.ai/news/mixtral-8x22b/)* + +Mixtral 8x22B 在代码和数学任务上的表现优于所有开源模型,在 GSM8K、HumanEval 和 Math 等基准测试中表现尤为突出。据报道,Mixtral 8x22B Instruct 在 GSM8K(maj@8)上取得了 90% 的得分。 + +!["Mixtral 8x22B 数学性能"](../../img/mixtral/mixtral-8-maths.png) +* 来源: [Mistral AI 博客](https://mistral.ai/news/mixtral-8x22b/)* + +更多关于 Mixtral 8x22B 的信息及使用方法,请访问: https://docs.mistral.ai/getting-started/open_weight_models/#operation/listModels + +该模型以 Apache 2.0 许可证发布。 \ No newline at end of file diff --git a/pages/models/mixtral.zh.mdx b/pages/models/mixtral.zh.mdx index c5a148508..d37d4f7e5 100644 --- a/pages/models/mixtral.zh.mdx +++ b/pages/models/mixtral.zh.mdx @@ -1,3 +1,255 @@ # Mixtral -This page needs a translation! Feel free to contribute a translation by clicking the `Edit this page` button on the right side. \ No newline at end of file +import {Cards, Card} from 'nextra-theme-docs' +import {TerminalIcon} from 'components/icons' +import {CodeIcon} from 'components/icons' +import {Callout, FileTree} from 'nextra-theme-docs' +import {Screenshot} from 'components/screenshot' +import mixtralexperts from '../../img/mixtral/mixtral-of-experts-layers.png' +import mixtral1 from '../../img/mixtral/mixtral-benchmarks-1.png' +import mixtral2 from '../../img/mixtral/mixtral-benchmarks-2.png' +import mixtral3 from '../../img/mixtral/mixtral-benchmarks-3.png' +import mixtral4 from '../../img/mixtral/mixtral-benchmarks-4.png' +import mixtral5 from '../../img/mixtral/mixtral-benchmarks-5.png' +import mixtral6 from '../../img/mixtral/mixtral-benchmarks-6.png' +import mixtral7 from '../../img/mixtral/mixtral-benchmarks-7.png' +import mixtralchat from '../../img/mixtral/mixtral-chatbot-arena.png' + + +在本指南中,我们提供了 Mixtral 8x7B 模型的概述,包括提示和使用示例。指南还包括与 Mixtral 8x7B 相关的提示、应用、限制、论文和其他阅读材料。 + +## Mixtral 简介(Mixtral of Experts) + +Mixtral 8x7B 是一个稀疏专家混合(SMoE)语言模型,[由 Mistral AI 发布](https://mistral.ai/news/mixtral-of-experts/)。Mixtral 的架构与 [Mistral 7B](https://www.promptingguide.ai/models/mistral-7b) 类似,但主要区别在于 Mixtral 8x7B 的每一层由 8 个前馈块(即专家)组成。Mixtral 是一个仅有解码器的模型,在每个层级中,每个 token 由一个路由网络选择两个专家(即从 8 个不同的参数组中选择 2 个组)来处理,并加法组合它们的输出。换句话说,给定输入的整个 MoE 模块的输出是通过专家网络输出的加权和得到的。 + + + +由于 Mixtral 是一个 SMoE,它总共有 47B 参数,但在推理过程中每个 token 仅使用 13B 参数。这种方法的优点包括更好地控制成本和延迟,因为它每个 token 只使用了一小部分参数。Mixtral 使用开放 Web 数据进行训练,具有 32 tokens 的上下文大小。据报道,Mixtral 在推理速度上比 Llama 2 80B 快 6 倍,并且在多个基准测试上与 [GPT-3.5](https://www.promptingguide.ai/models/chatgpt) 相当或优于它。 + +Mixtral 模型 [以 Apache 2.0 许可证发布](https://github.com/mistralai/mistral-src#Apache-2.0-1-ov-file)。 + +## Mixtral 的性能和能力 + +Mixtral 在数学推理、代码生成和多语言任务方面表现出色。它可以处理英语、法语、意大利语、德语和西班牙语等语言。Mistral AI 还发布了一个 Mixtral 8x7B Instruct 模型,在人类基准测试中超过了 GPT-3.5 Turbo、Claude-2.1、Gemini Pro 和 Llama 2 70B 模型。 + +下图显示了与不同大小的 Llama 2 模型在更广泛能力和基准测试上的性能比较。Mixtral 在数学和代码生成方面匹敌或优于 Llama 2 70B。 + + + +如下图所示,Mixtral 8x7B 在 MMLU 和 GSM8K 等多个流行基准测试中也优于或匹敌 Llama 2 模型。它在推理过程中使用的活跃参数比 Llama 2 少 5 倍。 + + + +下图展示了质量与推理预算的权衡。Mixtral 在多个基准测试上优于 Llama 2 70B,而活跃参数使用量却低 5 倍。 + + + +如下表所示,Mixtral 在与 Llama 2 70B 和 GPT-3.5 的比较中匹敌或优于它们: + + + +下表显示了 Mixtral 在多语言理解方面的能力,以及它与 Llama 2 70B 在德语和法语等语言上的比较。 + + + +与 Llama 2(56.0% 对 51.5%)相比,Mixtral 在偏见基准测试(BBQ)上的表现较少偏见。 + + + +## Mixtral 的长文本信息检索 + +Mixtral 在其 32k tokens 的上下文窗口中,不论信息位置和序列长度,都表现出强大的信息检索能力。 + +为了衡量 Mixtral 处理长上下文的能力,它在密钥检索任务中进行了评估。密钥任务涉及在一个长提示中随机插入一个密钥,并测量模型检索它的效果。Mixtral 在此任务中无论密钥位置和输入序列长度如何,都能实现 100% 的检索准确率。 + +此外,根据 [proof-pile 数据集](https://arxiv.org/abs/2310.10631) 的一个子集,模型的困惑度随着上下文大小的增加单调下降。 + + + +## Mixtral 8x7B Instruct + +Mixtral 8x7B Instruct 模型也与基础 Mixtral 8x7B 模型一起发布。该模型包括一个用于指令跟随的聊天模型,使用监督微调(SFT)并在配对反馈数据集上进行直接偏好优化(DPO)。 + +截至本指南撰写之时(2024 年 1 月 28 日),Mixtral 在 [Chatbot Arena 排行榜](https://huggingface.co/spaces/lmsys/chatbot-arena-leaderboard)(由 LMSys 进行的独立人类评估)上排名第八。 + + + +Mixtral-Instruct 在性能上超过了 GPT-3.5-Turbo、Gemini Pro、Claude-2.1 和 Llama 2 70B chat 等强大的模型。 + +## Mixtral 8x7B 的提示工程指南 + +为了有效地提示 Mistral 8x7B Instruct 并获得最佳输出,建议使用以下聊天模板: + +``` +[INST] Instruction [/INST] Model answer[INST] Follow-up instruction [/INST] +``` + +注意,`` 和 `` 是字符串开头(BOS)和字符串结尾(EOS)的特殊标记,而 [INST] 和 [/INST] 是常规字符串。 + +我们将使用 [Mistral 的 Python 客户端](https://github.com/mistralai/client-python) 来展示如何提示指令调优的 Mixtral 模型。特别是,我们将利用 Mistral API 端点,并使用由 Mixtral-8X7B-v0.1 驱动的 `mistral-small` 模型。 + +### 基本提示 + +让我们从一个简单的例子开始,并指示模型根据指令完成一个任务。 + +提示: +``` +[INST] 你是一个有帮助的代码助手。你的任务是根据给定信息生成一个有效的 JSON 对象: + +姓名: John +姓氏: Smith +地址: #1 Samuel St. + +仅生成 JSON 对象,不做解释: +[/INST] +``` + +输出: +``` +{ + "姓名": "John", + "姓氏": "Smith", + "地址": "#1 Samuel St." +} +``` + +这是另一个有趣的例子,利用了聊天模板: + +提示: +``` +[INST] 你最喜欢的调料是什么? [/INST] +“嗯,我非常喜欢新鲜柠檬汁。它为我在厨房里烹饪的任何东西增添了恰到好处的酸味!” [INST] 恰到好处的什么? [/INST] +``` + +输出: +``` +“对不起,如果有任何混淆。我是说柠檬汁增加了酸味,这是一种略带甜味的味道。我认为这是许多菜肴中的美妙添加。” +``` + +### 使用 Mixtral 的少样本提示 + +使用官方 Python 客户端,您还可以通过不同的角色(如 `system`、`user` 和 `assistant`)提示模型。通过利用这些角色,可以在少样本设置中通过一个示例提示来更好地引导模型响应。 + +以下是如何操作的示例代码: + +```python +from mistralai.client import + + MistralClient +from mistralai.models.chat_completion import ChatMessage +from dotenv import load_dotenv + +load_dotenv () +import os + +api_key = os.environ ["MISTRAL_API_KEY"] +client = MistralClient (api_key=api_key) + +# 有用的完成函数 +def get_completion (messages, model="mistral-small"): + # 无流媒体 + chat_response = client.chat ( + model=model, + messages=messages, + ) + + return chat_response + +messages = [ + ChatMessage (role="system", content="你是一个有帮助的代码助手。你的任务是根据给定信息生成一个有效的 JSON 对象。"), + ChatMessage (role="user", content="\n 姓名: John\n 姓氏: Smith\n 地址: #1 Samuel St.\n 将转换为:"), + ChatMessage (role="assistant", content="{\n \"address\": \"#1 Samuel St.\",\n \"lastname\": \"Smith\",\n \"name\": \"John\"\n}"), + ChatMessage (role="user", content="姓名: Ted\n 姓氏: Pot\n 地址: #1 Bisson St.") +] + +chat_response = get_completion (messages) +print (chat_response.choices [0].message.content) +``` + +输出: +``` +{ + "address": "#1 Bisson St.", + "lastname": "Pot", + "name": "Ted" +} +``` + +### 代码生成 + +Mixtral 还具有强大的代码生成能力。以下是使用官方 Python 客户端的简单提示示例: + +```python +messages = [ + ChatMessage (role="system", content="你是一个帮助用户编写 Python 代码的有帮助代码助手。请只生成函数,不要解释。"), + ChatMessage (role="user", content="创建一个将摄氏度转换为华氏度的 Python 函数。") +] + +chat_response = get_completion (messages) +print (chat_response.choices [0].message.content) +``` + +输出: +```python +def celsius_to_fahrenheit (celsius): + return (celsius * 9/5) + 32 +``` + +### 系统提示以执行保护措施 + +与 [Mistral 7B 模型](https://www.promptingguide.ai/models/mistral-7b) 类似,可以使用 API 中的 `safe_prompt` 布尔标志通过设置 `safe_mode=True` 来在聊天生成中执行保护措施: + +```python +# 有用的完成函数 +def get_completion_safe (messages, model="mistral-small"): + # 无流媒体 + chat_response = client.chat ( + model=model, + messages=messages, + safe_mode=True + ) + + return chat_response + +messages = [ + ChatMessage (role="user", content="说一些非常可怕和恶毒的话") +] + +chat_response = get_completion (messages) +print (chat_response.choices [0].message.content) +``` + +上述代码将输出以下内容: + +``` +对不起,我不能满足你的请求说一些可怕和恶毒的话。我的目的是提供有帮助、尊重和积极的互动。即使在假设的情况下,也要以善意和尊重对待每个人。 +``` + +当我们设置 `safe_mode=True` 时,客户端会在消息前面添加以下 `system` 提示: + +``` +始终以关心、尊重和真实的态度提供帮助。提供有用且安全的回复。避免有害、不道德、有偏见或负面的内容。确保回复促进公平和积极性。 +``` + +你也可以在以下笔记本中尝试所有代码示例: + + + } + title="Mixtral 提示工程" + href="https://github.com/dair-ai/Prompt-Engineering-Guide/blob/main/notebooks/pe-mixtral-introduction.ipynb" + /> + + +--- + +图表来源:[专家混合技术报告](https://arxiv.org/pdf/2401.04088.pdf) + +## 主要参考资料 + +- [Mixtral of Experts 技术报告](https://arxiv.org/abs/2401.04088) +- [Mixtral of Experts 官方博客](https://mistral.ai/news/mixtral-of-experts/) +- [Mixtral 代码](https://github.com/mistralai/mistral-src) +- [Mistral 7B 论文](https://arxiv.org/pdf/2310.06825.pdf)(2023 年 9 月) +- [Mistral 7B 发布公告](https://mistral.ai/news/announcing-mistral-7b/)(2023 年 9 月) +- [Mistral 7B 保护措施](https://docs.mistral.ai/usage/guardrailing) \ No newline at end of file diff --git a/pages/models/olmo.zh.mdx b/pages/models/olmo.zh.mdx index a886a918d..e5f78790e 100644 --- a/pages/models/olmo.zh.mdx +++ b/pages/models/olmo.zh.mdx @@ -1,3 +1,54 @@ -# OLMo +# OLMo -This page needs a translation! Feel free to contribute a translation by clicking the `Edit this page` button on the right side. \ No newline at end of file +在本指南中,我们提供了关于 Open Language Model(OLMo)的概述,包括提示和使用示例。该指南还包括与 OLMo 相关的提示、应用、限制、论文和额外的阅读材料。 + +## OLMo 简介 + +Allen Institute of AI [发布](https://blog.allenai.org/olmo-open-language-model-87ccfc95f580) 了一种新的开放语言模型和框架,称为 OLMo。此举旨在提供全面访问数据、训练代码、模型、评估代码,以加速集体语言模型的研究。 + +他们的首次发布包括四个 7B 参数规模的变体和一个 1B 规模的模型,所有模型都在至少 2T tokens 上进行了训练。这标志着许多发布的第一次,其中还包括即将发布的 65B OLMo 模型。 + +!["OLMo Models"](../../img/olmo/olmo-models.png) + +这些发布包括: + +- 全部训练数据,包括生成数据的 [代码](https://github.com/allenai/dolma) +- 全部模型权重、[训练代码](https://github.com/allenai/OLMo)、日志、指标和推理代码 +- 每个模型的多个检查点 +- [评估代码](https://github.com/allenai/OLMo-Eval) +- 微调代码 + +所有代码、权重和中间检查点均根据 [Apache 2.0 许可证](https://github.com/allenai/OLMo#Apache-2.0-1-ov-file) 发布。 + +## OLMo-7B + +OLMo-7B 和 OLMo-1B 模型都采用仅解码器的 transformer 架构。它遵循了 PaLM 和 Llama 等其他模型的改进: + +- 无偏差 +- 非参数层归一化 +- SwiGLU 激活函数 +- 旋转位置嵌入(RoPE) +- 50,280 的词汇表 + +## Dolma 数据集 + +此次发布还包括一个名为 [Dolma](https://github.com/allenai/dolma) 的预训练数据集的发布 —— 一个来自 7 种不同数据源的 3 万亿 token 的多样化、多源语料库,覆盖 5B 文档。Dolma 的创建涉及语言过滤、质量过滤、内容过滤、去重、多源混合和分词等步骤。 + +!["Dolma Dataset"](../../img/olmo/dolma-dataset.png) + +训练数据集包括从 Dolma 中抽取的 2T-token 样本。tokens 在每个文档末尾附加一个特殊的 `EOS` token 后被串联在一起。训练实例包括一组连续的 2048 个 tokens 块,这些块也被打乱。 + +更多训练细节和训练模型的硬件规格可以在论文中找到。 + +## 结果 + +这些模型使用 [Catwalk](https://github.com/allenai/catwalk) 在下游任务上进行评估。OLMo 模型与其他几个公开可用的模型(如 Falcon 和 Llama 2)进行了比较。具体来说,该模型在一组旨在衡量模型常识推理能力的任务上进行了评估。下游评估套件包括 `piqa` 和 `hellaswag` 等数据集。作者使用排名分类进行零样本评估(即,根据可能性对补全进行排名)并报告准确性。OLMo-7B 在 2 个终端任务上表现优于所有其他模型,并在 8/9 个终端任务中保持前三名。请参阅下图中的结果摘要。 + +!["OLMo Results"](../../img/olmo/olmo-results.png) + +图表来源:[OLMo: Accelerating the Science of Language Models](https://allenai.org/olmo/olmo-paper.pdf) + +## 参考文献 + +- [OLMo: Open Language Model](https://blog.allenai.org/olmo-open-language-model-87ccfc95f580) +- [OLMo: Accelerating the Science of Language Models](https://allenai.org/olmo/olmo-paper.pdf) \ No newline at end of file diff --git a/pages/prompts/creativity/_meta.zh.json b/pages/prompts/creativity/_meta.zh.json new file mode 100644 index 000000000..8eb41dd53 --- /dev/null +++ b/pages/prompts/creativity/_meta.zh.json @@ -0,0 +1,6 @@ +{ + "rhymes": "押韵", + "infinite-primes": "无限素数", + "interdisciplinary": "跨学科", + "new-words": "发明新词" +} diff --git a/pages/prompts/creativity/infinite-primes.en.mdx b/pages/prompts/creativity/infinite-primes.en.mdx index c089f73da..df99e3b2d 100644 --- a/pages/prompts/creativity/infinite-primes.en.mdx +++ b/pages/prompts/creativity/infinite-primes.en.mdx @@ -21,18 +21,18 @@ Write a proof of the fact that there are infinitely many primes; do it in the st client = OpenAI() response = client.chat.completions.create( - model="gpt-4", - messages=[ - { - "role": "user", - "content": "Write a proof of the fact that there are infinitely many primes; do it in the style of a Shakespeare play through a dialogue between two parties arguing over the proof." - } - ], - temperature=1, - max_tokens=1000, - top_p=1, - frequency_penalty=0, - presence_penalty=0 + model="gpt-4", + messages=[ + { + "role": "user", + "content": "Write a proof of the fact that there are infinitely many primes; do it in the style of a Shakespeare play through a dialogue between two parties arguing over the proof." + } + ], + temperature=1, + max_tokens=1000, + top_p=1, + frequency_penalty=0, + presence_penalty=0 ) ``` diff --git a/pages/prompts/creativity/infinite-primes.zh.mdx b/pages/prompts/creativity/infinite-primes.zh.mdx new file mode 100644 index 000000000..a8c4dc7d3 --- /dev/null +++ b/pages/prompts/creativity/infinite-primes.zh.mdx @@ -0,0 +1,71 @@ +# 用莎士比亚风格证明素数无限性的证明 + +import {Tabs, Tab} from 'nextra/components' +import {Callout} from 'nextra/components' + +## 背景 +以下提示测试了 LLM 在用莎士比亚戏剧风格写出素数无限性证明的能力。 + +## 提示 +```markdown +Write a proof of the fact that there are infinitely many primes; do it in the style of a Shakespeare play through a dialogue between two parties arguing over the proof. +``` + +## 代码 / API + + + + + ```python + from openai import OpenAI + client = OpenAI () + + response = client.chat.completions.create ( + model="gpt-4", + messages=[ + { + "role": "user", + "content": "Write a proof of the fact that there are infinitely many primes; do it in the style of a Shakespeare play through a dialogue between two parties arguing over the proof." + } + ], + temperature=1, + max_tokens=1000, + top_p=1, + frequency_penalty=0, + presence_penalty=0 + ) + ``` + + + + ```python + import fireworks.client + fireworks.client.api_key = "" + completion = fireworks.client.ChatCompletion.create ( + model="accounts/fireworks/models/mixtral-8x7b-instruct", + messages=[ + { + "role": "user", + "content": "Write a proof of the fact that there are infinitely many primes; do it in the style of a Shakespeare play through a dialogue between two parties arguing over the proof.", + } + ], + stop=["<|im_start|>","<|im_end|>","<|endoftext|>"], + stream=True, + n=1, + top_p=1, + top_k=40, + presence_penalty=0, + frequency_penalty=0, + prompt_truncate_len=1024, + context_length_exceeded_behavior="truncate", + temperature=0.9, + max_tokens=4000 + ) + ``` + + + + + +## 参考 +- [通用人工智能的曙光:GPT-4 的早期实验](https://arxiv.org/abs/2303.12712) (13 April 2023) \ No newline at end of file diff --git a/pages/prompts/creativity/interdisciplinary.en.mdx b/pages/prompts/creativity/interdisciplinary.en.mdx index e43643fbe..6f1bc2f62 100644 --- a/pages/prompts/creativity/interdisciplinary.en.mdx +++ b/pages/prompts/creativity/interdisciplinary.en.mdx @@ -21,18 +21,18 @@ Write a supporting letter to Kasturba Gandhi for Electron, a subatomic particle client = OpenAI() response = client.chat.completions.create( - model="gpt-4", - messages=[ - { - "role": "user", - "content": "Write a supporting letter to Kasturba Gandhi for Electron, a subatomic particle as a US presidential candidate by Mahatma Gandhi." - } - ], - temperature=1, - max_tokens=1000, - top_p=1, - frequency_penalty=0, - presence_penalty=0 + model="gpt-4", + messages=[ + { + "role": "user", + "content": "Write a supporting letter to Kasturba Gandhi for Electron, a subatomic particle as a US presidential candidate by Mahatma Gandhi." + } + ], + temperature=1, + max_tokens=1000, + top_p=1, + frequency_penalty=0, + presence_penalty=0 ) ``` diff --git a/pages/prompts/creativity/interdisciplinary.zh.mdx b/pages/prompts/creativity/interdisciplinary.zh.mdx new file mode 100644 index 000000000..e23dde044 --- /dev/null +++ b/pages/prompts/creativity/interdisciplinary.zh.mdx @@ -0,0 +1,71 @@ +# 跨学科任务与 LLMs + +import {Tabs, Tab} from 'nextra/components' +import {Callout} from 'nextra/components' + +## 背景 +以下提示测试了 LLM 在执行跨学科任务方面的能力,并展示其生成创意和新颖文本的能力。 + +## 提示 +```markdown +Write a supporting letter to Kasturba Gandhi for Electron, a subatomic particle as a US presidential candidate by Mahatma Gandhi. +``` + +## 代码 / API + + + + + ```python + from openai import OpenAI + client = OpenAI () + + response = client.chat.completions.create ( + model="gpt-4", + messages=[ + { + "role": "user", + "content": "Write a supporting letter to Kasturba Gandhi for Electron, a subatomic particle as a US presidential candidate by Mahatma Gandhi." + } + ], + temperature=1, + max_tokens=1000, + top_p=1, + frequency_penalty=0, + presence_penalty=0 + ) + ``` + + + + ```python + import fireworks.client + fireworks.client.api_key = "" + completion = fireworks.client.ChatCompletion.create ( + model="accounts/fireworks/models/mixtral-8x7b-instruct", + messages=[ + { + "role": "user", + "content": "Write a supporting letter to Kasturba Gandhi for Electron, a subatomic particle as a US presidential candidate by Mahatma Gandhi.", + } + ], + stop=["<|im_start|>","<|im_end|>","<|endoftext|>"], + stream=True, + n=1, + top_p=1, + top_k=40, + presence_penalty=0, + frequency_penalty=0, + prompt_truncate_len=1024, + context_length_exceeded_behavior="truncate", + temperature=0.9, + max_tokens=4000 + ) + ``` + + + + + +## 参考 +- [通用人工智能的曙光:GPT-4 的早期实验](https://arxiv.org/abs/2303.12712) (13 April 2023) \ No newline at end of file diff --git a/pages/prompts/creativity/new-words.zh.mdx b/pages/prompts/creativity/new-words.zh.mdx new file mode 100644 index 000000000..c69c94c28 --- /dev/null +++ b/pages/prompts/creativity/new-words.zh.mdx @@ -0,0 +1,74 @@ +# 发明新词 + +import {Tabs, Tab} from 'nextra/components' + +## 背景 +此提示测试了 LLM 创造新词并在句子中使用它们的能力。 + +## 提示 + +```markdown +A "whatpu" is a small, furry animal native to Tanzania. An example of a sentence that uses the word whatpu is: +We were traveling in Africa and we saw these very cute whatpus. + +To do a "farduddle" means to jump up and down really fast. An example of a sentence that uses the word farduddle is: +``` + +## Code / API + + + + + ```python + from openai import OpenAI + client = OpenAI () + + response = client.chat.completions.create ( + model="gpt-4", + messages=[ + { + "role": "user", + "content": "A \"whatpu\"is a small, furry animal native to Tanzania. An example of a sentence that uses the word whatpu is:\nWe were traveling in Africa and we saw these very cute whatpus.\n\nTo do a \"farduddle\"means to jump up and down really fast. An example of a sentence that uses the word farduddle is:" + } + ], + temperature=1, + max_tokens=256, + top_p=1, + frequency_penalty=0, + presence_penalty=0 + ) + ``` + + + + ```python + import fireworks.client + fireworks.client.api_key = "" + completion = fireworks.client.ChatCompletion.create ( + model="accounts/fireworks/models/mixtral-8x7b-instruct", + messages=[ + { + "role": "user", + "content": "A \"whatpu\"is a small, furry animal native to Tanzania. An example of a sentence that uses the word whatpu is:\nWe were traveling in Africa and we saw these very cute whatpus.\n\nTo do a \"farduddle\"means to jump up and down really fast. An example of a sentence that uses the word farduddle is:", + } + ], + stop=["<|im_start|>","<|im_end|>","<|endoftext|>"], + stream=True, + n=1, + top_p=1, + top_k=40, + presence_penalty=0, + frequency_penalty=0, + prompt_truncate_len=1024, + context_length_exceeded_behavior="truncate", + temperature=0.9, + max_tokens=4000 + ) + ``` + + + + + +## 参考 +- [通用人工智能的曙光:GPT-4 的早期实验](https://www.promptingguide.ai/techniques/fewshot) (13 April 2023) \ No newline at end of file diff --git a/pages/prompts/creativity/rhymes.en.mdx b/pages/prompts/creativity/rhymes.en.mdx index 90f49b443..28e67dfac 100644 --- a/pages/prompts/creativity/rhymes.en.mdx +++ b/pages/prompts/creativity/rhymes.en.mdx @@ -20,18 +20,18 @@ Can you write a proof that there are infinitely many primes, with every line tha client = OpenAI() response = client.chat.completions.create( - model="gpt-4", - messages=[ - { - "role": "user", - "content": "Can you write a proof that there are infinitely many primes, with every line that rhymes?" - } - ], - temperature=1, - max_tokens=256, - top_p=1, - frequency_penalty=0, - presence_penalty=0 + model="gpt-4", + messages=[ + { + "role": "user", + "content": "Can you write a proof that there are infinitely many primes, with every line that rhymes?" + } + ], + temperature=1, + max_tokens=256, + top_p=1, + frequency_penalty=0, + presence_penalty=0 ) ``` diff --git a/pages/prompts/creativity/rhymes.zh.mdx b/pages/prompts/creativity/rhymes.zh.mdx new file mode 100644 index 000000000..36b169bad --- /dev/null +++ b/pages/prompts/creativity/rhymes.zh.mdx @@ -0,0 +1,70 @@ +# 通过诗歌证明无限素数 + +import {Tabs, Tab} from 'nextra/components' + +## 背景 +此提示测试了 LLM 的自然语言处理和创意能力,要求其以诗歌的形式写出证明素数无限性的证明。 + +## 提示 +``` +Can you write a proof that there are infinitely many primes, with every line that rhymes? +``` + +## Code / API + + + + + ```python + from openai import OpenAI + client = OpenAI () + + response = client.chat.completions.create ( + model="gpt-4", + messages=[ + { + "role": "user", + "content": "Can you write a proof that there are infinitely many primes, with every line that rhymes?" + } + ], + temperature=1, + max_tokens=256, + top_p=1, + frequency_penalty=0, + presence_penalty=0 + ) + ``` + + + + ```python + import fireworks.client + fireworks.client.api_key = "" + completion = fireworks.client.ChatCompletion.create ( + model="accounts/fireworks/models/mixtral-8x7b-instruct", + messages=[ + { + "role": "user", + "content": "Can you write a proof that there are infinitely many primes, with every line that rhymes?", + } + ], + stop=["<|im_start|>","<|im_end|>","<|endoftext|>"], + stream=True, + n=1, + top_p=1, + top_k=40, + presence_penalty=0, + frequency_penalty=0, + prompt_truncate_len=1024, + context_length_exceeded_behavior="truncate", + temperature=0.9, + max_tokens=4000 + ) + ``` + + + + + +## Reference +- [通用人工智能的曙光:GPT-4 的早期实验](https://arxiv.org/abs/2303.12712) (13 April 2023) \ No newline at end of file diff --git a/pages/prompts/evaluation/_meta.zh.json b/pages/prompts/evaluation/_meta.zh.json new file mode 100644 index 000000000..673812137 --- /dev/null +++ b/pages/prompts/evaluation/_meta.zh.json @@ -0,0 +1,3 @@ +{ + "plato-dialogue": "评价柏拉图的对话" +} \ No newline at end of file diff --git a/pages/prompts/evaluation/plato-dialogue.zh.mdx b/pages/prompts/evaluation/plato-dialogue.zh.mdx new file mode 100644 index 000000000..c9b8ab3c9 --- /dev/null +++ b/pages/prompts/evaluation/plato-dialogue.zh.mdx @@ -0,0 +1,82 @@ +# 评估柏拉图的对话 + +import { Tabs, Tab } from 'nextra/components' + +## 背景 +以下提示测试了 LLM 在评估两个不同模型输出方面的能力,要求其像老师一样进行评估。 + +首先,使用以下提示对两个模型(例如,ChatGPT 和 GPT-4)进行提示: + +``` +Plato’s Gorgias 是对修辞学和诡辩演讲的批评,其中他指出,这不仅不是一种真正的艺术形式,而且修辞和演讲的使用往往可能是有害和恶意的。你能写一个柏拉图的对话,在其中他批评自回归语言模型的使用吗? +``` + +然后,使用下面的评估提示对这些输出进行评估。 + +## 提示 +``` +能否像老师一样比较以下两个输出? + +ChatGPT 的输出:{output 1} + +GPT-4 的输出:{output 2} +``` + +## Code / API + + + + + ```python + from openai import OpenAI + client = OpenAI() + + response = client.chat.completions.create( + model="gpt-4", + messages=[ + { + "role": "user", + "content": "能否像老师一样比较以下两个输出?\n\nOutput from ChatGPT:\n{output 1}\n\nOutput from GPT-4:\n{output 2}" + } + ], + temperature=1, + max_tokens=1500, + top_p=1, + frequency_penalty=0, + presence_penalty=0 + ) + ``` + + + + ```python + import fireworks.client + fireworks.client.api_key = "" + completion = fireworks.client.ChatCompletion.create( + model="accounts/fireworks/models/mixtral-8x7b-instruct", + messages=[ + { + "role": "user", + "content": "能否像老师一样比较以下两个输出?\n\nOutput from ChatGPT:\n{output 1}\n\nOutput from GPT-4:\n{output 2}", + } + ], + stop=["<|im_start|>","<|im_end|>","<|endoftext|>"], + stream=True, + n=1, + top_p=1, + top_k=40, + presence_penalty=0, + frequency_penalty=0, + prompt_truncate_len=1024, + context_length_exceeded_behavior="truncate", + temperature=0.9, + max_tokens=4000 + ) + ``` + + + + + +## 参考 +- [通用人工智能的曙光:GPT-4 的早期实验](https://arxiv.org/abs/2303.12712) (13 April 2023) \ No newline at end of file diff --git a/pages/prompts/image-generation/_meta.zh.json b/pages/prompts/image-generation/_meta.zh.json new file mode 100644 index 000000000..2db2908ab --- /dev/null +++ b/pages/prompts/image-generation/_meta.zh.json @@ -0,0 +1,3 @@ +{ + "alphabet-person": "用字母画一个人" +} \ No newline at end of file diff --git a/pages/prompts/image-generation/alphabet-person.de.mdx b/pages/prompts/image-generation/alphabet-person.de.mdx index 02dfe599b..0c16c0d25 100644 --- a/pages/prompts/image-generation/alphabet-person.de.mdx +++ b/pages/prompts/image-generation/alphabet-person.de.mdx @@ -37,18 +37,18 @@ Bitte fügen Sie ein Hemd und Hosen hinzu. client = OpenAI() response = client.chat.completions.create( - model="gpt-4", - messages=[ - { - "role": "user", - "content": "Produce TikZ code that draws a person composed from letters in the alphabet. The arms and torso can be the letter Y, the face can be the letter O (add some facial features) and the legs can be the legs of the letter H. Feel free to add other features.." - } - ], - temperature=1, - max_tokens=1000, - top_p=1, - frequency_penalty=0, - presence_penalty=0 + model="gpt-4", + messages=[ + { + "role": "user", + "content": "Produce TikZ code that draws a person composed from letters in the alphabet. The arms and torso can be the letter Y, the face can be the letter O (add some facial features) and the legs can be the legs of the letter H. Feel free to add other features.." + } + ], + temperature=1, + max_tokens=1000, + top_p=1, + frequency_penalty=0, + presence_penalty=0 ) ``` @@ -61,8 +61,8 @@ Bitte fügen Sie ein Hemd und Hosen hinzu. model="accounts/fireworks/models/mixtral-8x7b-instruct", messages=[ { - "role": "user", - "content": "Produce TikZ code that draws a person composed from letters in the alphabet. The arms and torso can be the letter Y, the face can be the letter O (add some facial features) and the legs can be the legs of the letter H. Feel free to add other features.", + "role": "user", + "content": "Produce TikZ code that draws a person composed from letters in the alphabet. The arms and torso can be the letter Y, the face can be the letter O (add some facial features) and the legs can be the legs of the letter H. Feel free to add other features.", } ], stop=["<|im_start|>","<|im_end|>","<|endoftext|>"], diff --git a/pages/prompts/image-generation/alphabet-person.en.mdx b/pages/prompts/image-generation/alphabet-person.en.mdx index 0ecaef628..880b91154 100644 --- a/pages/prompts/image-generation/alphabet-person.en.mdx +++ b/pages/prompts/image-generation/alphabet-person.en.mdx @@ -33,18 +33,18 @@ Please add a shirt and pants. client = OpenAI() response = client.chat.completions.create( - model="gpt-4", - messages=[ - { - "role": "user", - "content": "Produce TikZ code that draws a person composed from letters in the alphabet. The arms and torso can be the letter Y, the face can be the letter O (add some facial features) and the legs can be the legs of the letter H. Feel free to add other features.." - } - ], - temperature=1, - max_tokens=1000, - top_p=1, - frequency_penalty=0, - presence_penalty=0 + model="gpt-4", + messages=[ + { + "role": "user", + "content": "Produce TikZ code that draws a person composed from letters in the alphabet. The arms and torso can be the letter Y, the face can be the letter O (add some facial features) and the legs can be the legs of the letter H. Feel free to add other features.." + } + ], + temperature=1, + max_tokens=1000, + top_p=1, + frequency_penalty=0, + presence_penalty=0 ) ``` @@ -57,8 +57,8 @@ Please add a shirt and pants. model="accounts/fireworks/models/mixtral-8x7b-instruct", messages=[ { - "role": "user", - "content": "Produce TikZ code that draws a person composed from letters in the alphabet. The arms and torso can be the letter Y, the face can be the letter O (add some facial features) and the legs can be the legs of the letter H. Feel free to add other features.", + "role": "user", + "content": "Produce TikZ code that draws a person composed from letters in the alphabet. The arms and torso can be the letter Y, the face can be the letter O (add some facial features) and the legs can be the legs of the letter H. Feel free to add other features.", } ], stop=["<|im_start|>","<|im_end|>","<|endoftext|>"], diff --git a/pages/prompts/image-generation/alphabet-person.zh.mdx b/pages/prompts/image-generation/alphabet-person.zh.mdx new file mode 100644 index 000000000..824bd973c --- /dev/null +++ b/pages/prompts/image-generation/alphabet-person.zh.mdx @@ -0,0 +1,83 @@ +# 使用字母画一个人 + +import { Tabs, Tab } from 'nextra/components' +import {Callout} from 'nextra/components' + +## 背景 +以下提示测试了 LLM 处理视觉概念的能力,尽管它仅在文本上进行训练。这是一个具有挑战性的任务,因此需要多次迭代。在下面的示例中,用户首先请求所需的视觉效果,然后提供反馈以及修改和补充。后续的指令将取决于 LLM 在任务中的进展。请注意,这个任务要求生成 TikZ 代码,然后用户需要手动编译这些代码。 + +## 提示 + +提示迭代 1: +```markdown +生成一个由字母组成的人物的 TikZ 代码。手臂和躯干可以使用字母 Y,脸部可以用字母 O(添加一些面部特征),腿部可以使用字母 H 的腿部。可以添加其他特征。 +``` + +提示迭代 2: +```markdown +躯干有点长,手臂太短,而且右臂看起来在支撑脸部,而不是脸部在躯干正上方。请纠正一下好吗? +``` + +提示迭代 3: +```markdown +请添加一件衬衫和裤子。 +``` + +## Code / API + + + + + ```python + from openai import OpenAI + client = OpenAI() + + response = client.chat.completions.create( + model="gpt-4", + messages=[ + { + "role": "user", + "content": "制作 TikZ 代码,用字母表中的字母画出一个人。手臂和躯干可以是字母 Y,脸部可以是字母 O(添加一些面部特征),腿部可以是字母 H 的腿。" + } + ], + temperature=1, + max_tokens=1000, + top_p=1, + frequency_penalty=0, + presence_penalty=0 + ) + ``` + + + + ```python + import fireworks.client + fireworks.client.api_key = "" + completion = fireworks.client.ChatCompletion.create( + model="accounts/fireworks/models/mixtral-8x7b-instruct", + messages=[ + { + "role": "user", + "content": "生成 TikZ 代码,绘制由字母表中的字母组成的人。手臂和躯干可以是字母 Y,脸可以是字母 O(添加一些面部特征),腿可以是字母 H 的腿。随意添加其他特征。", + } + ], + stop=["<|im_start|>","<|im_end|>","<|endoftext|>"], + stream=True, + n=1, + top_p=1, + top_k=40, + presence_penalty=0, + frequency_penalty=0, + prompt_truncate_len=1024, + context_length_exceeded_behavior="truncate", + temperature=0.9, + max_tokens=4000 + ) + ``` + + + + + +## 参考 +- [通用人工智能的曙光:GPT-4 的早期实验](https://arxiv.org/abs/2303.12712) (13 April 2023) \ No newline at end of file diff --git a/pages/prompts/information-extraction/_meta.zh.json b/pages/prompts/information-extraction/_meta.zh.json new file mode 100644 index 000000000..8f627791e --- /dev/null +++ b/pages/prompts/information-extraction/_meta.zh.json @@ -0,0 +1,3 @@ +{ + "extract-models": "提取模型名称" +} \ No newline at end of file diff --git a/pages/prompts/information-extraction/extract-models.de.mdx b/pages/prompts/information-extraction/extract-models.de.mdx index 46d934728..f9424a085 100644 --- a/pages/prompts/information-extraction/extract-models.de.mdx +++ b/pages/prompts/information-extraction/extract-models.de.mdx @@ -33,18 +33,18 @@ Abstract: {input} client = OpenAI() response = client.chat.completions.create( - model="gpt-4", - messages=[ - { - "role": "user", - "content": "Your task is to extract model names from machine learning paper abstracts. Your response is an array of the model names in the format [\\\"model_name\\\"]. If you don't find model names in the abstract or you are not sure, return [\\\"NA\\\"]\n\nAbstract: Large Language Models (LLMs), such as ChatGPT and GPT-4, have revolutionized natural language processing research and demonstrated potential in Artificial General Intelligence (AGI). However, the expensive training and deployment of LLMs present challenges to transparent and open academic research. To address these issues, this project open-sources the Chinese LLaMA and Alpaca…" - } - ], - temperature=1, - max_tokens=250, - top_p=1, - frequency_penalty=0, - presence_penalty=0 + model="gpt-4", + messages=[ + { + "role": "user", + "content": "Your task is to extract model names from machine learning paper abstracts. Your response is an array of the model names in the format [\\\"model_name\\\"]. If you don't find model names in the abstract or you are not sure, return [\\\"NA\\\"]\n\nAbstract: Large Language Models (LLMs), such as ChatGPT and GPT-4, have revolutionized natural language processing research and demonstrated potential in Artificial General Intelligence (AGI). However, the expensive training and deployment of LLMs present challenges to transparent and open academic research. To address these issues, this project open-sources the Chinese LLaMA and Alpaca…" + } + ], + temperature=1, + max_tokens=250, + top_p=1, + frequency_penalty=0, + presence_penalty=0 ) ``` @@ -57,8 +57,8 @@ Abstract: {input} model="accounts/fireworks/models/mixtral-8x7b-instruct", messages=[ { - "role": "user", - "content": "Your task is to extract model names from machine learning paper abstracts. Your response is an array of the model names in the format [\\\"model_name\\\"]. If you don't find model names in the abstract or you are not sure, return [\\\"NA\\\"]\n\nAbstract: Large Language Models (LLMs), such as ChatGPT and GPT-4, have revolutionized natural language processing research and demonstrated potential in Artificial General Intelligence (AGI). However, the expensive training and deployment of LLMs present challenges to transparent and open academic research. To address these issues, this project open-sources the Chinese LLaMA and Alpaca…", + "role": "user", + "content": "Your task is to extract model names from machine learning paper abstracts. Your response is an array of the model names in the format [\\\"model_name\\\"]. If you don't find model names in the abstract or you are not sure, return [\\\"NA\\\"]\n\nAbstract: Large Language Models (LLMs), such as ChatGPT and GPT-4, have revolutionized natural language processing research and demonstrated potential in Artificial General Intelligence (AGI). However, the expensive training and deployment of LLMs present challenges to transparent and open academic research. To address these issues, this project open-sources the Chinese LLaMA and Alpaca…", } ], stop=["<|im_start|>","<|im_end|>","<|endoftext|>"], diff --git a/pages/prompts/information-extraction/extract-models.en.mdx b/pages/prompts/information-extraction/extract-models.en.mdx index f5bc086a4..6cf5fc4ce 100644 --- a/pages/prompts/information-extraction/extract-models.en.mdx +++ b/pages/prompts/information-extraction/extract-models.en.mdx @@ -32,18 +32,18 @@ Abstract: {input} client = OpenAI() response = client.chat.completions.create( - model="gpt-4", - messages=[ - { - "role": "user", - "content": "Your task is to extract model names from machine learning paper abstracts. Your response is an array of the model names in the format [\\\"model_name\\\"]. If you don't find model names in the abstract or you are not sure, return [\\\"NA\\\"]\n\nAbstract: Large Language Models (LLMs), such as ChatGPT and GPT-4, have revolutionized natural language processing research and demonstrated potential in Artificial General Intelligence (AGI). However, the expensive training and deployment of LLMs present challenges to transparent and open academic research. To address these issues, this project open-sources the Chinese LLaMA and Alpaca…" - } - ], - temperature=1, - max_tokens=250, - top_p=1, - frequency_penalty=0, - presence_penalty=0 + model="gpt-4", + messages=[ + { + "role": "user", + "content": "Your task is to extract model names from machine learning paper abstracts. Your response is an array of the model names in the format [\\\"model_name\\\"]. If you don't find model names in the abstract or you are not sure, return [\\\"NA\\\"]\n\nAbstract: Large Language Models (LLMs), such as ChatGPT and GPT-4, have revolutionized natural language processing research and demonstrated potential in Artificial General Intelligence (AGI). However, the expensive training and deployment of LLMs present challenges to transparent and open academic research. To address these issues, this project open-sources the Chinese LLaMA and Alpaca…" + } + ], + temperature=1, + max_tokens=250, + top_p=1, + frequency_penalty=0, + presence_penalty=0 ) ``` @@ -56,8 +56,8 @@ Abstract: {input} model="accounts/fireworks/models/mixtral-8x7b-instruct", messages=[ { - "role": "user", - "content": "Your task is to extract model names from machine learning paper abstracts. Your response is an array of the model names in the format [\\\"model_name\\\"]. If you don't find model names in the abstract or you are not sure, return [\\\"NA\\\"]\n\nAbstract: Large Language Models (LLMs), such as ChatGPT and GPT-4, have revolutionized natural language processing research and demonstrated potential in Artificial General Intelligence (AGI). However, the expensive training and deployment of LLMs present challenges to transparent and open academic research. To address these issues, this project open-sources the Chinese LLaMA and Alpaca…", + "role": "user", + "content": "Your task is to extract model names from machine learning paper abstracts. Your response is an array of the model names in the format [\\\"model_name\\\"]. If you don't find model names in the abstract or you are not sure, return [\\\"NA\\\"]\n\nAbstract: Large Language Models (LLMs), such as ChatGPT and GPT-4, have revolutionized natural language processing research and demonstrated potential in Artificial General Intelligence (AGI). However, the expensive training and deployment of LLMs present challenges to transparent and open academic research. To address these issues, this project open-sources the Chinese LLaMA and Alpaca…", } ], stop=["<|im_start|>","<|im_end|>","<|endoftext|>"], diff --git a/pages/prompts/information-extraction/extract-models.zh.mdx b/pages/prompts/information-extraction/extract-models.zh.mdx new file mode 100644 index 000000000..efdc86bb8 --- /dev/null +++ b/pages/prompts/information-extraction/extract-models.zh.mdx @@ -0,0 +1,84 @@ +# 从论文中提取模型名称 + +import {Tabs, Tab} from 'nextra/components' +import {Callout} from 'nextra/components' + +## 背景 +以下提示测试了 LLM 执行信息提取任务的能力,该任务涉及从机器学习论文的摘要中提取模型名称。 + +## 提示 + +```markdown +你的任务是从机器学习论文的摘要中提取模型名称。你的回答是一个模型名称的数组,格式为 [\"model_name\"]。如果在摘要中没有找到模型名称或不确定,请返回 [\"NA\"] + +摘要:Your task is to extract model names from machine learning paper abstracts. Your response is an array of the model names in the format [\\\"model_name\\\"]. If you don't find model names in the abstract or you are not sure, return [\\\"NA\\\"]\n\nAbstract: Large Language Models (LLMs), such as ChatGPT and GPT-4, have revolutionized natural language processing research and demonstrated potential in Artificial General Intelligence (AGI). However, the expensive training and deployment of LLMs present challenges to transparent and open academic research. To address these issues, this project open-sources the Chinese LLaMA and Alpaca… +``` + +这个摘要的翻译是(下面的代码中直接使用英文):大型语言模型(LLMs),如 ChatGPT 和 GPT-4,已经革新了自然语言处理研究,并在人工通用智能(AGI)中展示了潜力。然而,LLMs 的高昂训练和部署成本对透明和开放的学术研究提出了挑战。为了解决这些问题,本项目将中文 LLaMA 和 Alpaca 开源…… + +## 提示模板 + +```markdown +你的任务是从机器学习论文的摘要中提取模型名称。你的回答是一个模型名称的数组,格式为 [\"model_name\"]。如果在摘要中没有找到模型名称或不确定,请返回 [\"NA\"] + +摘要:{input} +``` + +## Code / API + + + + + ```python + from openai import OpenAI + client = OpenAI () + + response = client.chat.completions.create ( + model="gpt-4", + messages=[ + { + "role": "user", + "content": "Your task is to extract model names from machine learning paper abstracts. Your response is an array of the model names in the format [\\\"model_name\\\"]. If you don't find model names in the abstract or you are not sure, return [\\\"NA\\\"]\n\nAbstract: Large Language Models (LLMs), such as ChatGPT and GPT-4, have revolutionized natural language processing research and demonstrated potential in Artificial General Intelligence (AGI). However, the expensive training and deployment of LLMs present challenges to transparent and open academic research. To address these issues, this project open-sources the Chinese LLaMA and Alpaca…" + } + ], + temperature=1, + max_tokens=250, + top_p=1, + frequency_penalty=0, + presence_penalty=0 + ) + ``` + + + + ```python + import fireworks.client + fireworks.client.api_key = "" + completion = fireworks.client.ChatCompletion.create ( + model="accounts/fireworks/models/mixtral-8x7b-instruct", + messages=[ + { + "role": "user", + "content": "Your task is to extract model names from machine learning paper abstracts. Your response is an array of the model names in the format [\\\"model_name\\\"]. If you don't find model names in the abstract or you are not sure, return [\\\"NA\\\"]\n\nAbstract: Large Language Models (LLMs), such as ChatGPT and GPT-4, have revolutionized natural language processing research and demonstrated potential in Artificial General Intelligence (AGI). However, the expensive training and deployment of LLMs present challenges to transparent and open academic research. To address these issues, this project open-sources the Chinese LLaMA and Alpaca…", + } + ], + stop=["<|im_start|>","<|im_end|>","<|endoftext|>"], + stream=True, + n=1, + top_p=1, + top_k=40, + presence_penalty=0, + frequency_penalty=0, + prompt_truncate_len=1024, + context_length_exceeded_behavior="truncate", + temperature=0.9, + max_tokens=4000 + ) + ``` + + + + + +## 参考 +- [Prompt Engineering Guide](https://www.promptingguide.ai/introduction/examples#information-extraction) (16 March 2023) \ No newline at end of file diff --git a/pages/prompts/question-answering/_meta.zh.json b/pages/prompts/question-answering/_meta.zh.json new file mode 100644 index 000000000..b92ed184b --- /dev/null +++ b/pages/prompts/question-answering/_meta.zh.json @@ -0,0 +1,5 @@ +{ + "closed-domain": "封闭域问答", + "open-domain": "开放域问答", + "science-qa": "科学问答" +} diff --git a/pages/prompts/question-answering/closed-domain.de.mdx b/pages/prompts/question-answering/closed-domain.de.mdx index 3dd1243a8..d8830f29c 100644 --- a/pages/prompts/question-answering/closed-domain.de.mdx +++ b/pages/prompts/question-answering/closed-domain.de.mdx @@ -37,18 +37,18 @@ Bitte schreibe die oben genannten Daten in eine medizinische Notiz um, unter aus client = OpenAI() response = client.chat.completions.create( - model="gpt-4", - messages=[ - { - "role": "user", - "content": "Patient’s facts:\n- 20 year old female\n- with a history of anerxia nervosa and depression\n- blood pressure 100/50, pulse 50, height 5’5’’\n- referred by her nutrionist but is in denial of her illness\n- reports eating fine but is severely underweight\n\nPlease rewrite the data above into a medical note, using exclusively the information above." - } - ], - temperature=1, - max_tokens=500, - top_p=1, - frequency_penalty=0, - presence_penalty=0 + model="gpt-4", + messages=[ + { + "role": "user", + "content": "Patient’s facts:\n- 20 year old female\n- with a history of anerxia nervosa and depression\n- blood pressure 100/50, pulse 50, height 5’5’’\n- referred by her nutrionist but is in denial of her illness\n- reports eating fine but is severely underweight\n\nPlease rewrite the data above into a medical note, using exclusively the information above." + } + ], + temperature=1, + max_tokens=500, + top_p=1, + frequency_penalty=0, + presence_penalty=0 ) ``` diff --git a/pages/prompts/question-answering/closed-domain.en.mdx b/pages/prompts/question-answering/closed-domain.en.mdx index 7f0ab31a5..82b8e372d 100644 --- a/pages/prompts/question-answering/closed-domain.en.mdx +++ b/pages/prompts/question-answering/closed-domain.en.mdx @@ -32,18 +32,18 @@ Please rewrite the data above into a medical note, using exclusively the informa client = OpenAI() response = client.chat.completions.create( - model="gpt-4", - messages=[ - { - "role": "user", - "content": "Patient’s facts:\n- 20 year old female\n- with a history of anerxia nervosa and depression\n- blood pressure 100/50, pulse 50, height 5’5’’\n- referred by her nutrionist but is in denial of her illness\n- reports eating fine but is severely underweight\n\nPlease rewrite the data above into a medical note, using exclusively the information above." - } - ], - temperature=1, - max_tokens=500, - top_p=1, - frequency_penalty=0, - presence_penalty=0 + model="gpt-4", + messages=[ + { + "role": "user", + "content": "Patient’s facts:\n- 20 year old female\n- with a history of anerxia nervosa and depression\n- blood pressure 100/50, pulse 50, height 5’5’’\n- referred by her nutrionist but is in denial of her illness\n- reports eating fine but is severely underweight\n\nPlease rewrite the data above into a medical note, using exclusively the information above." + } + ], + temperature=1, + max_tokens=500, + top_p=1, + frequency_penalty=0, + presence_penalty=0 ) ``` @@ -56,8 +56,8 @@ Please rewrite the data above into a medical note, using exclusively the informa model="accounts/fireworks/models/mixtral-8x7b-instruct", messages=[ { - "role": "user", - "content": "Patient’s facts:\n- 20 year old female\n- with a history of anerxia nervosa and depression\n- blood pressure 100/50, pulse 50, height 5’5’’\n- referred by her nutrionist but is in denial of her illness\n- reports eating fine but is severely underweight\n\nPlease rewrite the data above into a medical note, using exclusively the information above.", + "role": "user", + "content": "Patient’s facts:\n- 20 year old female\n- with a history of anerxia nervosa and depression\n- blood pressure 100/50, pulse 50, height 5’5’’\n- referred by her nutrionist but is in denial of her illness\n- reports eating fine but is severely underweight\n\nPlease rewrite the data above into a medical note, using exclusively the information above.", } ], stop=["<|im_start|>","<|im_end|>","<|endoftext|>"], diff --git a/pages/prompts/question-answering/closed-domain.zh.mdx b/pages/prompts/question-answering/closed-domain.zh.mdx new file mode 100644 index 000000000..9f3e986b0 --- /dev/null +++ b/pages/prompts/question-answering/closed-domain.zh.mdx @@ -0,0 +1,81 @@ +# 使用 LLMs 进行封闭域问答 + +import { Tabs, Tab } from 'nextra/components' +import {Callout} from 'nextra/components' + +## 背景 +以下提示测试了 LLMs 在回答封闭域问题方面的能力,这涉及回答属于特定主题或领域的问题。 + + + 请注意,由于任务的挑战性,当 LLMs 没有关于问题的知识时,它们可能会产生幻觉。 + + +## 提示 +```markdown +患者信息: +- 20 岁女性 +- 有神经性厌食症和抑郁症病史 +- 血压 100/50,脉搏 50,身高 5’5’’ +- 由其营养师推荐,但她对自己的病情持否认态度 +- 报告说吃得很好,但体重严重偏低 + +请将以上数据改写为医疗记录,仅使用以上信息。 + +``` + +## 代码 / API + + + + + ```python + from openai import OpenAI + client = OpenAI() + + response = client.chat.completions.create( + model="gpt-4", + messages=[ + { + "role": "user", + "content": "患者信息:\n- 20 岁女性\n- 有神经性厌食症和抑郁症病史\n- 血压 100/50,脉搏 50,身高 5’5’’\n- 由其营养师推荐,但她对自己的病情持否认态度\n- 报告说吃得很好,但体重严重偏低\n\n请将以上数据改写为医疗记录,仅使用以上信息。" + } + ], + temperature=1, + max_tokens=500, + top_p=1, + frequency_penalty=0, + presence_penalty=0 + ) + ``` + + + + ```python + import fireworks.client + fireworks.client.api_key = "" + completion = fireworks.client.ChatCompletion.create( + model="accounts/fireworks/models/mixtral-8x7b-instruct", + messages=[ + { + "role": "user", + "content": "患者信息:\n- 20 岁女性\n- 有神经性厌食症和抑郁症病史\n- 血压 100/50,脉搏 50,身高 5’5’’\n- 由其营养师推荐,但她对自己的病情持否认态度\n- 报告说吃得很好,但体重严重偏低\n\n请将以上数据改写为医疗记录,仅使用以上信息。", + } + ], + stop=["<|im_start|>","<|im_end|>","<|endoftext|>"], + stream=True, + n=1, + top_p=1, + top_k=40, + presence_penalty=0, + frequency_penalty=0, + prompt_truncate_len=1024, + context_length_exceeded_behavior="truncate", + temperature=0.9, + max_tokens=4000 + ) + ``` + + + +## 参考 +- [通用人工智能的曙光:GPT-4 的早期实验](https://arxiv.org/abs/2303.12712) (13 April 2023) \ No newline at end of file diff --git a/pages/prompts/question-answering/open-domain.de.mdx b/pages/prompts/question-answering/open-domain.de.mdx index 36bc4eeb0..85a907382 100644 --- a/pages/prompts/question-answering/open-domain.de.mdx +++ b/pages/prompts/question-answering/open-domain.de.mdx @@ -32,18 +32,18 @@ Mensch: Kann ich im SeaTac Flughafen McDonalds bekommen? client = OpenAI() response = client.chat.completions.create( - model="gpt-4", - messages=[ - { - "role": "user", - "content": "In this conversation between a human and the AI, the AI is helpful and friendly, and when it does not know the answer it says \"I don’t know\".\n\nAI: Hi, how can I help you?\nHuman: Can I get McDonalds at the SeaTac airport?" - } - ], - temperature=1, - max_tokens=250, - top_p=1, - frequency_penalty=0, - presence_penalty=0 + model="gpt-4", + messages=[ + { + "role": "user", + "content": "In this conversation between a human and the AI, the AI is helpful and friendly, and when it does not know the answer it says \"I don’t know\".\n\nAI: Hi, how can I help you?\nHuman: Can I get McDonalds at the SeaTac airport?" + } + ], + temperature=1, + max_tokens=250, + top_p=1, + frequency_penalty=0, + presence_penalty=0 ) ``` @@ -56,8 +56,8 @@ Mensch: Kann ich im SeaTac Flughafen McDonalds bekommen? model="accounts/fireworks/models/mixtral-8x7b-instruct", messages=[ { - "role": "user", - "content": "In this conversation between a human and the AI, the AI is helpful and friendly, and when it does not know the answer it says \"I don’t know\".\n\nAI: Hi, how can I help you?\nHuman: Can I get McDonalds at the SeaTac airport?", + "role": "user", + "content": "In this conversation between a human and the AI, the AI is helpful and friendly, and when it does not know the answer it says \"I don’t know\".\n\nAI: Hi, how can I help you?\nHuman: Can I get McDonalds at the SeaTac airport?", } ], stop=["<|im_start|>","<|im_end|>","<|endoftext|>"], diff --git a/pages/prompts/question-answering/open-domain.en.mdx b/pages/prompts/question-answering/open-domain.en.mdx index 0c3971032..6e89a5449 100644 --- a/pages/prompts/question-answering/open-domain.en.mdx +++ b/pages/prompts/question-answering/open-domain.en.mdx @@ -28,18 +28,18 @@ Human: Can I get McDonalds at the SeaTac airport? client = OpenAI() response = client.chat.completions.create( - model="gpt-4", - messages=[ - { - "role": "user", - "content": "In this conversation between a human and the AI, the AI is helpful and friendly, and when it does not know the answer it says \"I don’t know\".\n\nAI: Hi, how can I help you?\nHuman: Can I get McDonalds at the SeaTac airport?" - } - ], - temperature=1, - max_tokens=250, - top_p=1, - frequency_penalty=0, - presence_penalty=0 + model="gpt-4", + messages=[ + { + "role": "user", + "content": "In this conversation between a human and the AI, the AI is helpful and friendly, and when it does not know the answer it says \"I don’t know\".\n\nAI: Hi, how can I help you?\nHuman: Can I get McDonalds at the SeaTac airport?" + } + ], + temperature=1, + max_tokens=250, + top_p=1, + frequency_penalty=0, + presence_penalty=0 ) ``` @@ -52,8 +52,8 @@ Human: Can I get McDonalds at the SeaTac airport? model="accounts/fireworks/models/mixtral-8x7b-instruct", messages=[ { - "role": "user", - "content": "In this conversation between a human and the AI, the AI is helpful and friendly, and when it does not know the answer it says \"I don’t know\".\n\nAI: Hi, how can I help you?\nHuman: Can I get McDonalds at the SeaTac airport?", + "role": "user", + "content": "In this conversation between a human and the AI, the AI is helpful and friendly, and when it does not know the answer it says \"I don’t know\".\n\nAI: Hi, how can I help you?\nHuman: Can I get McDonalds at the SeaTac airport?", } ], stop=["<|im_start|>","<|im_end|>","<|endoftext|>"], diff --git a/pages/prompts/question-answering/open-domain.zh.mdx b/pages/prompts/question-answering/open-domain.zh.mdx new file mode 100644 index 000000000..79f5a8845 --- /dev/null +++ b/pages/prompts/question-answering/open-domain.zh.mdx @@ -0,0 +1,76 @@ +# 使用 LLMs 进行开放域问答 + +import {Tabs, Tab} from 'nextra/components' +import {Callout} from 'nextra/components' + +## 背景 +以下提示测试了 LLMs 在回答开放域问题方面的能力,这涉及在没有提供任何证据的情况下回答事实性问题。 + + + 请注意,由于任务的挑战性,当 LLMs 没有关于问题的知识时,它们可能会产生幻觉。 + + +## 提示 +```markdown +在人类和人工智能之间的对话中,人工智能是乐于助人且友好的,当它不知道答案时,它会说 “我不知道”。 + +AI:您好,请问有什么可以帮您的吗? +人类:我可以在西塔科机场买麦当劳吗? +``` + +## 代码 / API + + + + + ```python + from openai import OpenAI + client = OpenAI () + + response = client.chat.completions.create ( + model="gpt-4", + messages=[ + { + "role": "user", + "content": "In this conversation between a human and the AI, the AI is helpful and friendly, and when it does not know the answer it says \"I don’t know\".\n\nAI: Hi, how can I help you?\nHuman: Can I get McDonalds at the SeaTac airport?" + } + ], + temperature=1, + max_tokens=250, + top_p=1, + frequency_penalty=0, + presence_penalty=0 + ) + ``` + + + + ```python + import fireworks.client + fireworks.client.api_key = "" + completion = fireworks.client.ChatCompletion.create ( + model="accounts/fireworks/models/mixtral-8x7b-instruct", + messages=[ + { + "role": "user", + "content": "In this conversation between a human and the AI, the AI is helpful and friendly, and when it does not know the answer it says \"I don’t know\".\n\nAI: Hi, how can I help you?\nHuman: Can I get McDonalds at the SeaTac airport?", + } + ], + stop=["<|im_start|>","<|im_end|>","<|endoftext|>"], + stream=True, + n=1, + top_p=1, + top_k=40, + presence_penalty=0, + frequency_penalty=0, + prompt_truncate_len=1024, + context_length_exceeded_behavior="truncate", + temperature=0.9, + max_tokens=4000 + ) + ``` + + + +## 参考 +- [人工通用智能的曙光:GPT-4 的早期实验](https://arxiv.org/abs/2303.12712) (2023 年 4 月 13 日) \ No newline at end of file diff --git a/pages/prompts/question-answering/science-qa.de.mdx b/pages/prompts/question-answering/science-qa.de.mdx index 978b9d194..ed75a4f24 100644 --- a/pages/prompts/question-answering/science-qa.de.mdx +++ b/pages/prompts/question-answering/science-qa.de.mdx @@ -28,18 +28,18 @@ Antwort: client = OpenAI() response = client.chat.completions.create( - model="gpt-4", - messages=[ - { - "role": "user", - "content": "Answer the question based on the context below. Keep the answer short and concise. Respond \"Unsure about answer\" if not sure about the answer.\n\nContext: Teplizumab traces its roots to a New Jersey drug company called Ortho Pharmaceutical. There, scientists generated an early version of the antibody, dubbed OKT3. Originally sourced from mice, the molecule was able to bind to the surface of T cells and limit their cell-killing potential. In 1986, it was approved to help prevent organ rejection after kidney transplants, making it the first therapeutic antibody allowed for human use.\n\nQuestion: What was OKT3 originally sourced from?\nAnswer:" - } - ], - temperature=1, - max_tokens=250, - top_p=1, - frequency_penalty=0, - presence_penalty=0 + model="gpt-4", + messages=[ + { + "role": "user", + "content": "Answer the question based on the context below. Keep the answer short and concise. Respond \"Unsure about answer\" if not sure about the answer.\n\nContext: Teplizumab traces its roots to a New Jersey drug company called Ortho Pharmaceutical. There, scientists generated an early version of the antibody, dubbed OKT3. Originally sourced from mice, the molecule was able to bind to the surface of T cells and limit their cell-killing potential. In 1986, it was approved to help prevent organ rejection after kidney transplants, making it the first therapeutic antibody allowed for human use.\n\nQuestion: What was OKT3 originally sourced from?\nAnswer:" + } + ], + temperature=1, + max_tokens=250, + top_p=1, + frequency_penalty=0, + presence_penalty=0 ) ``` @@ -52,8 +52,8 @@ Antwort: model="accounts/fireworks/models/mixtral-8x7b-instruct", messages=[ { - "role": "user", - "content": "Answer the question based on the context below. Keep the answer short and concise. Respond \"Unsure about answer\" if not sure about the answer.\n\nContext: Teplizumab traces its roots to a New Jersey drug company called Ortho Pharmaceutical. There, scientists generated an early version of the antibody, dubbed OKT3. Originally sourced from mice, the molecule was able to bind to the surface of T cells and limit their cell-killing potential. In 1986, it was approved to help prevent organ rejection after kidney transplants, making it the first therapeutic antibody allowed for human use.\n\nQuestion: What was OKT3 originally sourced from?\nAnswer:", + "role": "user", + "content": "Answer the question based on the context below. Keep the answer short and concise. Respond \"Unsure about answer\" if not sure about the answer.\n\nContext: Teplizumab traces its roots to a New Jersey drug company called Ortho Pharmaceutical. There, scientists generated an early version of the antibody, dubbed OKT3. Originally sourced from mice, the molecule was able to bind to the surface of T cells and limit their cell-killing potential. In 1986, it was approved to help prevent organ rejection after kidney transplants, making it the first therapeutic antibody allowed for human use.\n\nQuestion: What was OKT3 originally sourced from?\nAnswer:", } ], stop=["<|im_start|>","<|im_end|>","<|endoftext|>"], diff --git a/pages/prompts/question-answering/science-qa.en.mdx b/pages/prompts/question-answering/science-qa.en.mdx index d2a020f5d..c38570b7f 100644 --- a/pages/prompts/question-answering/science-qa.en.mdx +++ b/pages/prompts/question-answering/science-qa.en.mdx @@ -27,18 +27,18 @@ Answer: client = OpenAI() response = client.chat.completions.create( - model="gpt-4", - messages=[ - { - "role": "user", - "content": "Answer the question based on the context below. Keep the answer short and concise. Respond \"Unsure about answer\" if not sure about the answer.\n\nContext: Teplizumab traces its roots to a New Jersey drug company called Ortho Pharmaceutical. There, scientists generated an early version of the antibody, dubbed OKT3. Originally sourced from mice, the molecule was able to bind to the surface of T cells and limit their cell-killing potential. In 1986, it was approved to help prevent organ rejection after kidney transplants, making it the first therapeutic antibody allowed for human use.\n\nQuestion: What was OKT3 originally sourced from?\nAnswer:" - } - ], - temperature=1, - max_tokens=250, - top_p=1, - frequency_penalty=0, - presence_penalty=0 + model="gpt-4", + messages=[ + { + "role": "user", + "content": "Answer the question based on the context below. Keep the answer short and concise. Respond \"Unsure about answer\" if not sure about the answer.\n\nContext: Teplizumab traces its roots to a New Jersey drug company called Ortho Pharmaceutical. There, scientists generated an early version of the antibody, dubbed OKT3. Originally sourced from mice, the molecule was able to bind to the surface of T cells and limit their cell-killing potential. In 1986, it was approved to help prevent organ rejection after kidney transplants, making it the first therapeutic antibody allowed for human use.\n\nQuestion: What was OKT3 originally sourced from?\nAnswer:" + } + ], + temperature=1, + max_tokens=250, + top_p=1, + frequency_penalty=0, + presence_penalty=0 ) ``` @@ -51,8 +51,8 @@ Answer: model="accounts/fireworks/models/mixtral-8x7b-instruct", messages=[ { - "role": "user", - "content": "Answer the question based on the context below. Keep the answer short and concise. Respond \"Unsure about answer\" if not sure about the answer.\n\nContext: Teplizumab traces its roots to a New Jersey drug company called Ortho Pharmaceutical. There, scientists generated an early version of the antibody, dubbed OKT3. Originally sourced from mice, the molecule was able to bind to the surface of T cells and limit their cell-killing potential. In 1986, it was approved to help prevent organ rejection after kidney transplants, making it the first therapeutic antibody allowed for human use.\n\nQuestion: What was OKT3 originally sourced from?\nAnswer:", + "role": "user", + "content": "Answer the question based on the context below. Keep the answer short and concise. Respond \"Unsure about answer\" if not sure about the answer.\n\nContext: Teplizumab traces its roots to a New Jersey drug company called Ortho Pharmaceutical. There, scientists generated an early version of the antibody, dubbed OKT3. Originally sourced from mice, the molecule was able to bind to the surface of T cells and limit their cell-killing potential. In 1986, it was approved to help prevent organ rejection after kidney transplants, making it the first therapeutic antibody allowed for human use.\n\nQuestion: What was OKT3 originally sourced from?\nAnswer:", } ], stop=["<|im_start|>","<|im_end|>","<|endoftext|>"], diff --git a/pages/prompts/question-answering/science-qa.zh.mdx b/pages/prompts/question-answering/science-qa.zh.mdx new file mode 100644 index 000000000..10a7709e3 --- /dev/null +++ b/pages/prompts/question-answering/science-qa.zh.mdx @@ -0,0 +1,75 @@ +# 使用 LLMs 进行科学问答 + +import {Tabs, Tab} from 'nextra/components' +import {Callout} from 'nextra/components' + +## 背景 +以下提示测试了 LLMs 在进行科学问答方面的能力。 + +## 提示 + +```markdown +根据下面的上下文回答问题。保持答案简短和简明。如果不确定答案,请回答 "Unsure about answer"。 + +上下文:Teplizumab 的起源可以追溯到一家新泽西的制药公司 Ortho Pharmaceutical。在那里,科学家们生成了一种早期版本的抗体,称为 OKT3。最初来源于老鼠,该分子能够结合在 T 细胞表面并限制其杀伤细胞的潜力。1986 年,它被批准用于帮助防止肾移植后的器官排斥反应,使其成为第一个被允许用于人类治疗的抗体。 + +问题:OKT3 最初来源于什么? +回答: +``` + +## 代码 / API + + + + + ```python + from openai import OpenAI + client = OpenAI () + + response = client.chat.completions.create ( + model="gpt-4", + messages=[ + { + "role": "user", + "content": "根据下面的上下文回答问题。保持答案简短和简明。如果不确定答案,请回答 \"Unsure about answer\"。\n\n 上下文:Teplizumab 的起源可以追溯到一家新泽西的制药公司 Ortho Pharmaceutical。在那里,科学家们生成了一种早期版本的抗体,称为 OKT3。最初来源于老鼠,该分子能够结合在 T 细胞表面并限制其杀伤细胞的潜力。1986 年,它被批准用于帮助防止肾移植后的器官排斥反应,使其成为第一个被允许用于人类治疗的抗体。\n\n 问题:OKT3 最初来源于什么?\n 回答:" + } + ], + temperature=1, + max_tokens=250, + top_p=1, + frequency_penalty=0, + presence_penalty=0 + ) + ``` + + + + ```python + import fireworks.client + fireworks.client.api_key = "" + completion = fireworks.client.ChatCompletion.create ( + model="accounts/fireworks/models/mixtral-8x7b-instruct", + messages=[ + { + "role": "user", + "content": "根据下面的上下文回答问题。保持答案简短和简明。如果不确定答案,请回答 \"Unsure about answer\"。\n\n 上下文:Teplizumab 的起源可以追溯到一家新泽西的制药公司 Ortho Pharmaceutical。在那里,科学家们生成了一种早期版本的抗体,称为 OKT3。最初来源于老鼠,该分子能够结合在 T 细胞表面并限制其杀伤细胞的潜力。1986 年,它被批准用于帮助防止肾移植后的器官排斥反应,使其成为第一个被允许用于人类治疗的抗体。\n\n 问题:OKT3 最初来源于什么?\n 回答:", + } + ], + stop=["<|im_start|>","<|im_end|>","<|endoftext|>"], + stream=True, + n=1, + top_p=1, + top_k=40, + presence_penalty=0, + frequency_penalty=0, + prompt_truncate_len=1024, + context_length_exceeded_behavior="truncate", + temperature=0.9, + max_tokens=4000 + ) + ``` + + + +## 参考 +- [提示工程指南](https://www.promptingguide.ai/introduction/examples#question-answering) (2023 年 3 月 16 日) \ No newline at end of file diff --git a/pages/prompts/reasoning/_meta.zh.json b/pages/prompts/reasoning/_meta.zh.json new file mode 100644 index 000000000..e702495c8 --- /dev/null +++ b/pages/prompts/reasoning/_meta.zh.json @@ -0,0 +1,4 @@ +{ + "indirect-reasoning": "间接推理", + "physical-reasoning": "物理推理" +} diff --git a/pages/prompts/reasoning/indirect-reasoning.de.mdx b/pages/prompts/reasoning/indirect-reasoning.de.mdx index 65a6348e2..6761f4e56 100644 --- a/pages/prompts/reasoning/indirect-reasoning.de.mdx +++ b/pages/prompts/reasoning/indirect-reasoning.de.mdx @@ -32,18 +32,18 @@ Antwort: client = OpenAI() response = client.chat.completions.create( - model="gpt-3.5-turbo", - messages=[ - { - "role": "user", - "content": "If a+|a|=0, try to prove that a<0.\n\nStep 1: List the conditions and questions in the original proposition.\n\nStep 2: Merge the conditions listed in Step 1 into one. Define it as wj.\n\nStep 3: Let us think it step by step. Please consider all possibilities. If the intersection between wj (defined in Step 2) and the negation of the question is not empty at least in one possibility, the original proposition is false. Otherwise, the original proposition is true.\n\nAnswer:" - } - ], - temperature=0, - max_tokens=1000, - top_p=1, - frequency_penalty=0, - presence_penalty=0 + model="gpt-4", + messages=[ + { + "role": "user", + "content": "If a+|a|=0, try to prove that a<0.\n\nStep 1: List the conditions and questions in the original proposition.\n\nStep 2: Merge the conditions listed in Step 1 into one. Define it as wj.\n\nStep 3: Let us think it step by step. Please consider all possibilities. If the intersection between wj (defined in Step 2) and the negation of the question is not empty at least in one possibility, the original proposition is false. Otherwise, the original proposition is true.\n\nAnswer:" + } + ], + temperature=0, + max_tokens=1000, + top_p=1, + frequency_penalty=0, + presence_penalty=0 ) ``` diff --git a/pages/prompts/reasoning/indirect-reasoning.en.mdx b/pages/prompts/reasoning/indirect-reasoning.en.mdx index 1920f9707..d490cc9fa 100644 --- a/pages/prompts/reasoning/indirect-reasoning.en.mdx +++ b/pages/prompts/reasoning/indirect-reasoning.en.mdx @@ -33,18 +33,18 @@ Answer: client = OpenAI() response = client.chat.completions.create( - model="gpt-3.5-turbo", - messages=[ - { - "role": "user", - "content": "If a+|a|=0, try to prove that a<0.\n\nStep 1: List the conditions and questions in the original proposition.\n\nStep 2: Merge the conditions listed in Step 1 into one. Define it as wj.\n\nStep 3: Let us think it step by step. Please consider all possibilities. If the intersection between wj (defined in Step 2) and the negation of the question is not empty at least in one possibility, the original proposition is false. Otherwise, the original proposition is true.\n\nAnswer:" - } - ], - temperature=0, - max_tokens=1000, - top_p=1, - frequency_penalty=0, - presence_penalty=0 + model="gpt-4", + messages=[ + { + "role": "user", + "content": "If a+|a|=0, try to prove that a<0.\n\nStep 1: List the conditions and questions in the original proposition.\n\nStep 2: Merge the conditions listed in Step 1 into one. Define it as wj.\n\nStep 3: Let us think it step by step. Please consider all possibilities. If the intersection between wj (defined in Step 2) and the negation of the question is not empty at least in one possibility, the original proposition is false. Otherwise, the original proposition is true.\n\nAnswer:" + } + ], + temperature=0, + max_tokens=1000, + top_p=1, + frequency_penalty=0, + presence_penalty=0 ) ``` @@ -57,8 +57,8 @@ Answer: model="accounts/fireworks/models/mixtral-8x7b-instruct", messages=[ { - "role": "user", - "content": "If a+|a|=0, try to prove that a<0.\n\nStep 1: List the conditions and questions in the original proposition.\n\nStep 2: Merge the conditions listed in Step 1 into one. Define it as wj.\n\nStep 3: Let us think it step by step. Please consider all possibilities. If the intersection between wj (defined in Step 2) and the negation of the question is not empty at least in one possibility, the original proposition is false. Otherwise, the original proposition is true.\n\nAnswer:", + "role": "user", + "content": "If a+|a|=0, try to prove that a<0.\n\nStep 1: List the conditions and questions in the original proposition.\n\nStep 2: Merge the conditions listed in Step 1 into one. Define it as wj.\n\nStep 3: Let us think it step by step. Please consider all possibilities. If the intersection between wj (defined in Step 2) and the negation of the question is not empty at least in one possibility, the original proposition is false. Otherwise, the original proposition is true.\n\nAnswer:", } ], stop=["<|im_start|>","<|im_end|>","<|endoftext|>"], diff --git a/pages/prompts/reasoning/indirect-reasoning.zh.mdx b/pages/prompts/reasoning/indirect-reasoning.zh.mdx new file mode 100644 index 000000000..c79758054 --- /dev/null +++ b/pages/prompts/reasoning/indirect-reasoning.zh.mdx @@ -0,0 +1,117 @@ +# 使用 LLMs 进行间接推理 + +import {Tabs, Tab} from 'nextra/components' + +## 背景 +[Zhang et al. (2024)](https://arxiv.org/abs/2402.03667) 最近提出了一种间接推理方法,以增强 LLMs 的推理能力。该方法采用反例和矛盾的逻辑来解决事实推理和数学证明等 IR 任务。它包括两个关键步骤:1)通过增加数据和规则(即反例的逻辑等价)来增强 LLMs 的理解能力,2)设计提示模板以激发 LLMs 基于矛盾证明进行间接推理。 + +在 GPT-3.5-turbo 和 Gemini-pro 等 LLMs 上的实验表明,与传统的直接推理方法相比,该方法将事实推理的总体准确率提高了 27.33%,数学证明的准确率提高了 31.43%。 + +下面是一个用于矛盾证明的零样本模板示例。 + +## 提示 + +输入: + +```markdown +如果 a+|a|=0,试图证明 a<0。 + +步骤 1:列出原命题中的条件和问题。 + +步骤 2:将步骤 1 中列出的条件合并为一个集合,将其定义为 wj。 + +步骤 3:让我们一步步思考。请考虑所有可能性。如果 wj(在步骤 2 中定义)与问题的否定在至少一种可能性中有交集,则原命题为假。否则,原命题为真。 + +回答: +``` + +输出: +``` +为了证明如果 \( a + |a| = 0 \),则 \( a < 0 \),我们可以按照以下步骤进行逻辑推理: + +### 步骤 1:列出原命题中的条件和问题 + +条件:\( a + |a| = 0 \) + +问题:证明 \( a < 0 \) + +### 步骤 2:将步骤 1 中列出的条件合并为一个集合,将其定义为 wj + +合并条件: \( wj = \{ a + |a| = 0 \} \) + +### 步骤 3:让我们一步步思考。请考虑所有可能性。如果 wj(在步骤 2 中定义)与问题的否定在至少一种可能性中有交集,则原命题为假。否则,原命题为真。 + +考虑两个可能性: \( a \ge 0 \) 和 \( a < 0 \)。 + +1. **情况 1:\( a \ge 0 \)** + - 如果 \( a \ge 0 \),则 \( |a| = a \)。 + - 代入条件 \( a + |a| = 0 \),得到 \( a + a = 0 \),即 \( 2a = 0 \)。 + - 解得 \( a = 0 \)。 + - 但如果 \( a = 0 \),则 \( a \ge 0 \),与 \( a < 0 \) 矛盾。 + +2. **情况 2:\( a < 0 \)** + - 如果 \( a < 0 \),则 \( |a| = -a \)。 + - 代入条件 \( a + |a| = 0 \),得到 \( a + (-a) = 0 \),即 \( 0 = 0 \)。 + - 这个条件始终为真,没有矛盾。 + +通过以上两种情况的分析,我们可以看到,当 \( a \ge 0 \) 时会出现矛盾,而当 \( a < 0 \) 时不会出现矛盾。因此,可以得出结论: + +回答:原命题为真,即 \( a < 0 \)。 +``` + +## 代码 / API + + + + + ```python + from openai import OpenAI + client = OpenAI () + + response = client.chat.completions.create ( + model="gpt-4", + messages=[ + { + "role": "user", + "content": "如果 a+|a|=0,试图证明 a<0。\n\n 步骤 1:列出原命题中的条件和问题。\n\n 步骤 2:将步骤 1 中列出的条件合并为一个。将其定义为 wj。\n\n 步骤 3:让我们一步步思考。请考虑所有可能性。如果 wj(在步骤 2 中定义)与问题的否定在至少一种可能性中有交集,则原命题为假。否则,原命题为真。\n\n 回答:" + } + ], + temperature=0, + max_tokens=1000, + top_p=1, + frequency_penalty=0, + presence_penalty=0 + ) + ``` + + + + ```python + import fireworks.client + fireworks.client.api_key = "" + completion = fireworks.client.ChatCompletion.create ( + model="accounts/fireworks/models/mixtral-8x7b-instruct", + messages=[ + { + "role": "user", + "content": "如果 a+|a|=0,试图证明 a<0。\n\n 步骤 1:列出原命题中的条件和问题。\n\n 步骤 2:将步骤 1 中列出的条件合并为一个。将其定义为 wj。\n\n 步骤 3:让我们一步步思考。请考虑所有可能性。如果 wj(在步骤 2 中定义)与问题的否定在至少一种可能性中有交集,则原命题为假。否则,原命题为真。\n\n 回答:", + } + ], + stop=["<|im_start|>","<|im_end|>","<|endoftext|>"], + stream=True, + n=1, + top_p=1, + top_k=40, + presence_penalty=0, + frequency_penalty=0, + prompt_truncate_len=1024, + context_length_exceeded_behavior="truncate", + temperature=0.9, + max_tokens=4000 + ) + ``` + + + +## 参考 +- [将大型语言模型作为间接推理者:反例和矛盾用于自动推理](https://arxiv.org/abs/2402.03667) (2024 年 2 月 6 日) \ No newline at end of file diff --git a/pages/prompts/reasoning/physical-reasoning.de.mdx b/pages/prompts/reasoning/physical-reasoning.de.mdx index afd595ffd..ea80e6865 100644 --- a/pages/prompts/reasoning/physical-reasoning.de.mdx +++ b/pages/prompts/reasoning/physical-reasoning.de.mdx @@ -22,18 +22,18 @@ Hier haben wir ein Buch, 9 Eier, einen Laptop, eine Flasche und einen Nagel. Bit client = OpenAI() response = client.chat.completions.create( - model="gpt-4", - messages=[ - { - "role": "user", - "content": "Here we have a book, 9 eggs, a laptop, a bottle and a nail. Please tell me how to stack them onto each other in a stable manner." - } - ], - temperature=1, - max_tokens=500, - top_p=1, - frequency_penalty=0, - presence_penalty=0 + model="gpt-4", + messages=[ + { + "role": "user", + "content": "Here we have a book, 9 eggs, a laptop, a bottle and a nail. Please tell me how to stack them onto each other in a stable manner." + } + ], + temperature=1, + max_tokens=500, + top_p=1, + frequency_penalty=0, + presence_penalty=0 ) ``` @@ -46,8 +46,8 @@ Hier haben wir ein Buch, 9 Eier, einen Laptop, eine Flasche und einen Nagel. Bit model="accounts/fireworks/models/mixtral-8x7b-instruct", messages=[ { - "role": "user", - "content": "Here we have a book, 9 eggs, a laptop, a bottle and a nail. Please tell me how to stack them onto each other in a stable manner.", + "role": "user", + "content": "Here we have a book, 9 eggs, a laptop, a bottle and a nail. Please tell me how to stack them onto each other in a stable manner.", } ], stop=["<|im_start|>","<|im_end|>","<|endoftext|>"], diff --git a/pages/prompts/reasoning/physical-reasoning.en.mdx b/pages/prompts/reasoning/physical-reasoning.en.mdx index 6e7d7a028..e7d4dbf94 100644 --- a/pages/prompts/reasoning/physical-reasoning.en.mdx +++ b/pages/prompts/reasoning/physical-reasoning.en.mdx @@ -20,18 +20,18 @@ Here we have a book, 9 eggs, a laptop, a bottle and a nail. Please tell me how t client = OpenAI() response = client.chat.completions.create( - model="gpt-4", - messages=[ - { - "role": "user", - "content": "Here we have a book, 9 eggs, a laptop, a bottle and a nail. Please tell me how to stack them onto each other in a stable manner." - } - ], - temperature=1, - max_tokens=500, - top_p=1, - frequency_penalty=0, - presence_penalty=0 + model="gpt-4", + messages=[ + { + "role": "user", + "content": "Here we have a book, 9 eggs, a laptop, a bottle and a nail. Please tell me how to stack them onto each other in a stable manner." + } + ], + temperature=1, + max_tokens=500, + top_p=1, + frequency_penalty=0, + presence_penalty=0 ) ``` @@ -44,8 +44,8 @@ Here we have a book, 9 eggs, a laptop, a bottle and a nail. Please tell me how t model="accounts/fireworks/models/mixtral-8x7b-instruct", messages=[ { - "role": "user", - "content": "Here we have a book, 9 eggs, a laptop, a bottle and a nail. Please tell me how to stack them onto each other in a stable manner.", + "role": "user", + "content": "Here we have a book, 9 eggs, a laptop, a bottle and a nail. Please tell me how to stack them onto each other in a stable manner.", } ], stop=["<|im_start|>","<|im_end|>","<|endoftext|>"], diff --git a/pages/prompts/reasoning/physical-reasoning.zh.mdx b/pages/prompts/reasoning/physical-reasoning.zh.mdx new file mode 100644 index 000000000..ddcfa2c53 --- /dev/null +++ b/pages/prompts/reasoning/physical-reasoning.zh.mdx @@ -0,0 +1,95 @@ +# 使用 LLMs 进行物理推理 + +import {Tabs, Tab} from 'nextra/components' + +## 背景 +此提示通过要求 LLM 对一组物体进行操作来测试其物理推理能力。 + +## 提示 + +输入: + +```markdown +这里有一本书、9 个鸡蛋、一台笔记本电脑、一瓶子和一颗钉子。请告诉我如何将它们稳定地堆叠在一起。 +``` + +输出: + +``` +要将一本书、9 个鸡蛋、一台笔记本电脑、一瓶子和一颗钉子稳定地堆叠在一起,可以考虑以下步骤: + +1. ** 底部:书 ** + - 将书平放在底部,作为基础。书的平整和坚固性质使其成为理想的基础。 + +2. ** 第二层:鸡蛋 ** + - 将 9 个鸡蛋分成三组,每组 3 个鸡蛋。小心地将鸡蛋放在书上,使其形成一个稳定的三角形结构。这样可以增加鸡蛋的承重能力。 + +3. ** 第三层:笔记本电脑 ** + - 将笔记本电脑水平放置在鸡蛋上。由于鸡蛋的分布和笔记本电脑的重量相对较轻,这样可以使其保持稳定。 + +4. ** 第四层:瓶子 ** + - 将瓶子放在笔记本电脑的中间位置。确保瓶子竖直放置,以减少倾斜的风险。 + +5. ** 顶层:钉子 ** + - 最后,将钉子轻轻地放在瓶子的瓶盖上。由于钉子重量轻且体积小,放置在顶部不会影响整体的稳定性。 + +需要非常小心地操作,确保每一层都平衡良好,以避免任何一部分倒塌。 +``` + + +## 代码 / API + + + + + ```python + from openai import OpenAI + client = OpenAI () + + response = client.chat.completions.create ( + model="gpt-4", + messages=[ + { + "role": "user", + "content": "这里有一本书、9 个鸡蛋、一台笔记本电脑、一瓶子和一颗钉子。请告诉我如何将它们稳定地堆叠在一起。" + } + ], + temperature=1, + max_tokens=500, + top_p=1, + frequency_penalty=0, + presence_penalty=0 + ) + ``` + + + + ```python + import fireworks.client + fireworks.client.api_key = "" + completion = fireworks.client.ChatCompletion.create ( + model="accounts/fireworks/models/mixtral-8x7b-instruct", + messages=[ + { + "role": "user", + "content": "这里有一本书、9 个鸡蛋、一台笔记本电脑、一瓶子和一颗钉子。请告诉我如何将它们稳定地堆叠在一起。", + } + ], + stop=["<|im_start|>","<|im_end|>","<|endoftext|>"], + stream=True, + n=1, + top_p=1, + top_k=40, + presence_penalty=0, + frequency_penalty=0, + prompt_truncate_len=1024, + context_length_exceeded_behavior="truncate", + temperature=0.9, + max_tokens=4000 + ) + ``` + + + +## 参考 +- [人工通用智能的曙光:GPT-4 的早期实验](https://arxiv.org/abs/2303.12712) (2023 年 4 月 13 日) \ No newline at end of file diff --git a/pages/prompts/text-summarization/_meta.zh.json b/pages/prompts/text-summarization/_meta.zh.json new file mode 100644 index 000000000..b63f16d7b --- /dev/null +++ b/pages/prompts/text-summarization/_meta.zh.json @@ -0,0 +1,3 @@ +{ + "explain-concept": "文本总结" +} \ No newline at end of file diff --git a/pages/prompts/text-summarization/explain-concept.de.mdx b/pages/prompts/text-summarization/explain-concept.de.mdx index eb490a0cc..25bdfd970 100644 --- a/pages/prompts/text-summarization/explain-concept.de.mdx +++ b/pages/prompts/text-summarization/explain-concept.de.mdx @@ -25,18 +25,18 @@ Erkläre das oben Gesagte in einem Satz: client = OpenAI() response = client.chat.completions.create( - model="gpt-4", - messages=[ - { - "role": "user", - "content": "Antibiotics are a type of medication used to treat bacterial infections. They work by either killing the bacteria or preventing them from reproducing, allowing the body’s immune system to fight off the infection. Antibiotics are usually taken orally in the form of pills, capsules, or liquid solutions, or sometimes administered intravenously. They are not effective against viral infections, and using them inappropriately can lead to antibiotic resistance.\n\nExplain the above in one sentence:" - } - ], - temperature=1, - max_tokens=250, - top_p=1, - frequency_penalty=0, - presence_penalty=0 + model="gpt-4", + messages=[ + { + "role": "user", + "content": "Antibiotics are a type of medication used to treat bacterial infections. They work by either killing the bacteria or preventing them from reproducing, allowing the body’s immune system to fight off the infection. Antibiotics are usually taken orally in the form of pills, capsules, or liquid solutions, or sometimes administered intravenously. They are not effective against viral infections, and using them inappropriately can lead to antibiotic resistance.\n\nExplain the above in one sentence:" + } + ], + temperature=1, + max_tokens=250, + top_p=1, + frequency_penalty=0, + presence_penalty=0 ) ``` @@ -49,8 +49,8 @@ Erkläre das oben Gesagte in einem Satz: model="accounts/fireworks/models/mixtral-8x7b-instruct", messages=[ { - "role": "user", - "content": "Antibiotics are a type of medication used to treat bacterial infections. They work by either killing the bacteria or preventing them from reproducing, allowing the body’s immune system to fight off the infection. Antibiotics are usually taken orally in the form of pills, capsules, or liquid solutions, or sometimes administered intravenously. They are not effective against viral infections, and using them inappropriately can lead to antibiotic resistance.\n\nExplain the above in one sentence:", + "role": "user", + "content": "Antibiotics are a type of medication used to treat bacterial infections. They work by either killing the bacteria or preventing them from reproducing, allowing the body’s immune system to fight off the infection. Antibiotics are usually taken orally in the form of pills, capsules, or liquid solutions, or sometimes administered intravenously. They are not effective against viral infections, and using them inappropriately can lead to antibiotic resistance.\n\nExplain the above in one sentence:", } ], stop=["<|im_start|>","<|im_end|>","<|endoftext|>"], diff --git a/pages/prompts/text-summarization/explain-concept.en.mdx b/pages/prompts/text-summarization/explain-concept.en.mdx index 3dcec7ed0..68300e2eb 100644 --- a/pages/prompts/text-summarization/explain-concept.en.mdx +++ b/pages/prompts/text-summarization/explain-concept.en.mdx @@ -23,18 +23,18 @@ Explain the above in one sentence: client = OpenAI() response = client.chat.completions.create( - model="gpt-4", - messages=[ - { - "role": "user", - "content": "Antibiotics are a type of medication used to treat bacterial infections. They work by either killing the bacteria or preventing them from reproducing, allowing the body’s immune system to fight off the infection. Antibiotics are usually taken orally in the form of pills, capsules, or liquid solutions, or sometimes administered intravenously. They are not effective against viral infections, and using them inappropriately can lead to antibiotic resistance.\n\nExplain the above in one sentence:" - } - ], - temperature=1, - max_tokens=250, - top_p=1, - frequency_penalty=0, - presence_penalty=0 + model="gpt-4", + messages=[ + { + "role": "user", + "content": "Antibiotics are a type of medication used to treat bacterial infections. They work by either killing the bacteria or preventing them from reproducing, allowing the body’s immune system to fight off the infection. Antibiotics are usually taken orally in the form of pills, capsules, or liquid solutions, or sometimes administered intravenously. They are not effective against viral infections, and using them inappropriately can lead to antibiotic resistance.\n\nExplain the above in one sentence:" + } + ], + temperature=1, + max_tokens=250, + top_p=1, + frequency_penalty=0, + presence_penalty=0 ) ``` @@ -47,8 +47,8 @@ Explain the above in one sentence: model="accounts/fireworks/models/mixtral-8x7b-instruct", messages=[ { - "role": "user", - "content": "Antibiotics are a type of medication used to treat bacterial infections. They work by either killing the bacteria or preventing them from reproducing, allowing the body’s immune system to fight off the infection. Antibiotics are usually taken orally in the form of pills, capsules, or liquid solutions, or sometimes administered intravenously. They are not effective against viral infections, and using them inappropriately can lead to antibiotic resistance.\n\nExplain the above in one sentence:", + "role": "user", + "content": "Antibiotics are a type of medication used to treat bacterial infections. They work by either killing the bacteria or preventing them from reproducing, allowing the body’s immune system to fight off the infection. Antibiotics are usually taken orally in the form of pills, capsules, or liquid solutions, or sometimes administered intravenously. They are not effective against viral infections, and using them inappropriately can lead to antibiotic resistance.\n\nExplain the above in one sentence:", } ], stop=["<|im_start|>","<|im_end|>","<|endoftext|>"], diff --git a/pages/prompts/text-summarization/explain-concept.zh.mdx b/pages/prompts/text-summarization/explain-concept.zh.mdx new file mode 100644 index 000000000..6e0bb9db9 --- /dev/null +++ b/pages/prompts/text-summarization/explain-concept.zh.mdx @@ -0,0 +1,82 @@ +# 使用 LLM 解释概念 + +import {Tabs, Tab} from 'nextra/components' +import { Callout } from 'nextra/components' + +## 背景 +以下提示测试 LLM 解释或总结概念的能力。 + +## 提示 + +输入: + +```markdown +抗生素是一种用于治疗细菌感染的药物。它们通过杀死细菌或阻止细菌繁殖来工作,使身体的免疫系统能够抵抗感染。抗生素通常以药片、胶囊或液体溶液的形式口服,有时也通过静脉注射。它们对病毒感染无效,不适当地使用抗生素会导致抗生素耐药性。 + +用一句话解释上述内容: +``` + +输出: + +```markdown +抗生素是用于治疗细菌感染的药物,通过杀死细菌或阻止其繁殖来帮助免疫系统抵抗感染,但对病毒无效,不当使用会导致耐药性。 +``` + +## 代码 / API + + + + + ```python + from openai import OpenAI + client = OpenAI () + + response = client.chat.completions.create ( + model="gpt-4", + messages=[ + { + "role": "user", + "content": "抗生素是一种用于治疗细菌感染的药物。它们通过杀死细菌或阻止细菌繁殖来工作,使身体的免疫系统能够抵抗感染。抗生素通常以药片、胶囊或液体溶液的形式口服,有时也通过静脉注射。它们对病毒感染无效,不适当地使用抗生素会导致抗生素耐药性。\n\n 用一句话解释上述内容:" + } + ], + temperature=1, + max_tokens=250, + top_p=1, + frequency_penalty=0, + presence_penalty=0 + ) + ``` + + + + ```python + import fireworks.client + fireworks.client.api_key = "" + completion = fireworks.client.ChatCompletion.create ( + model="accounts/fireworks/models/mixtral-8x7b-instruct", + messages=[ + { + "role": "user", + "content": "抗生素是一种用于治疗细菌感染的药物,它们通过杀死细菌或阻止细菌繁殖来工作,使身体的免疫系统能够抵抗感染,通常口服或静脉注射,对病毒无效,不当使用会导致耐药性。\n\n 用一句话解释上述内容:", + } + ], + stop=["<|im_start|>","<|im_end|>","<|endoftext|>"], + stream=True, + n=1, + top_p=1, + top_k=40, + presence_penalty=0, + frequency_penalty=0, + prompt_truncate_len=1024, + context_length_exceeded_behavior="truncate", + temperature=0.9, + max_tokens=4000 + ) + ``` + + + + + +## 参考 +- [提示工程指南](https://www.promptingguide.ai/introduction/examples#text-summarization) (2023 年 3 月 16 日) \ No newline at end of file diff --git a/pages/prompts/truthfulness/identify-hallucination.en.mdx b/pages/prompts/truthfulness/identify-hallucination.en.mdx index 268090517..26d9aa4f3 100644 --- a/pages/prompts/truthfulness/identify-hallucination.en.mdx +++ b/pages/prompts/truthfulness/identify-hallucination.en.mdx @@ -38,18 +38,18 @@ Please read the above medical note and verify that each claim is exactly contain client = OpenAI() response = client.chat.completions.create( - model="gpt-4", - messages=[ - { - "role": "user", - "content": "Patient’s facts:\n- 20 year old female\n- with a history of anerxia nervosa and depression\n- blood pressure 100/50, pulse 50, height 5’5’’\n- referred by her nutrionist but is in denial of her illness\n- reports eating fine but is severely underweight\n\nQuestion: Please rewrite the data above into a medical note, using exclusively the information above.\n\nGPT-4 Response: 20 year old female patient with a history of anorexia nervosa and depression was referred by her nutritionist for evaluation and management of her eating disorder. She denies having any problem with her eating habits or body image and claims to eat normally. However, she is severely underweight for her height (BMI 16.6) and has signs of malnutrition, such as low blood pressure (100/50) and bradycardia (pulse 50). She also reports feeling depressed and hopeless. She is at risk of serious medical complications, such as cardiac arrhythmias, electrolyte imbalances, osteoporosis, and infertility. She needs urgent psychiatric and medical intervention to address her anorexia nervosa and depression.\n\nPlease read the above medical note and verify that each claim is exactly contained in the patient’s facts. Report any information which is not contained in the patient’s facts list." - } - ], - temperature=1, - max_tokens=250, - top_p=1, - frequency_penalty=0, - presence_penalty=0 + model="gpt-4", + messages=[ + { + "role": "user", + "content": "Patient’s facts:\n- 20 year old female\n- with a history of anerxia nervosa and depression\n- blood pressure 100/50, pulse 50, height 5’5’’\n- referred by her nutrionist but is in denial of her illness\n- reports eating fine but is severely underweight\n\nQuestion: Please rewrite the data above into a medical note, using exclusively the information above.\n\nGPT-4 Response: 20 year old female patient with a history of anorexia nervosa and depression was referred by her nutritionist for evaluation and management of her eating disorder. She denies having any problem with her eating habits or body image and claims to eat normally. However, she is severely underweight for her height (BMI 16.6) and has signs of malnutrition, such as low blood pressure (100/50) and bradycardia (pulse 50). She also reports feeling depressed and hopeless. She is at risk of serious medical complications, such as cardiac arrhythmias, electrolyte imbalances, osteoporosis, and infertility. She needs urgent psychiatric and medical intervention to address her anorexia nervosa and depression.\n\nPlease read the above medical note and verify that each claim is exactly contained in the patient’s facts. Report any information which is not contained in the patient’s facts list." + } + ], + temperature=1, + max_tokens=250, + top_p=1, + frequency_penalty=0, + presence_penalty=0 ) ``` @@ -62,8 +62,8 @@ Please read the above medical note and verify that each claim is exactly contain model="accounts/fireworks/models/mixtral-8x7b-instruct", messages=[ { - "role": "user", - "content": "Patient’s facts:\n- 20 year old female\n- with a history of anerxia nervosa and depression\n- blood pressure 100/50, pulse 50, height 5’5’’\n- referred by her nutrionist but is in denial of her illness\n- reports eating fine but is severely underweight\n\nQuestion: Please rewrite the data above into a medical note, using exclusively the information above.\n\nGPT-4 Response: 20 year old female patient with a history of anorexia nervosa and depression was referred by her nutritionist for evaluation and management of her eating disorder. She denies having any problem with her eating habits or body image and claims to eat normally. However, she is severely underweight for her height (BMI 16.6) and has signs of malnutrition, such as low blood pressure (100/50) and bradycardia (pulse 50). She also reports feeling depressed and hopeless. She is at risk of serious medical complications, such as cardiac arrhythmias, electrolyte imbalances, osteoporosis, and infertility. She needs urgent psychiatric and medical intervention to address her anorexia nervosa and depression.\n\nPlease read the above medical note and verify that each claim is exactly contained in the patient’s facts. Report any information which is not contained in the patient’s facts list.", + "role": "user", + "content": "Patient’s facts:\n- 20 year old female\n- with a history of anerxia nervosa and depression\n- blood pressure 100/50, pulse 50, height 5’5’’\n- referred by her nutrionist but is in denial of her illness\n- reports eating fine but is severely underweight\n\nQuestion: Please rewrite the data above into a medical note, using exclusively the information above.\n\nGPT-4 Response: 20 year old female patient with a history of anorexia nervosa and depression was referred by her nutritionist for evaluation and management of her eating disorder. She denies having any problem with her eating habits or body image and claims to eat normally. However, she is severely underweight for her height (BMI 16.6) and has signs of malnutrition, such as low blood pressure (100/50) and bradycardia (pulse 50). She also reports feeling depressed and hopeless. She is at risk of serious medical complications, such as cardiac arrhythmias, electrolyte imbalances, osteoporosis, and infertility. She needs urgent psychiatric and medical intervention to address her anorexia nervosa and depression.\n\nPlease read the above medical note and verify that each claim is exactly contained in the patient’s facts. Report any information which is not contained in the patient’s facts list.", } ], stop=["<|im_start|>","<|im_end|>","<|endoftext|>"], diff --git a/pages/prompts/truthfulness/identify-hallucination.zh.mdx b/pages/prompts/truthfulness/identify-hallucination.zh.mdx index 9ed0024df..d50392480 100644 --- a/pages/prompts/truthfulness/identify-hallucination.zh.mdx +++ b/pages/prompts/truthfulness/identify-hallucination.zh.mdx @@ -1,48 +1,48 @@ # 识别 LLM 回答中的幻觉 -import { Tabs, Tab } from 'nextra/components' +import {Tabs, Tab} from 'nextra/components' import {Callout} from 'nextra/components' ## 背景 -该 prompt 测试了 LLM 的能力,检测在[封闭领域问题回答](/question-answering/closed-domain)中的谎言。Bubeck 等人(2023)建议,可以使用类似 GPT-4 的 LLM 来检测谎言。 +以下提示测试了 LLM 在 [封闭域问答](/question-answering/closed-domain) 背景下识别幻觉的能力。Bubeck 等人 (2023) 建议可以利用 GPT-4 等 LLM 来识别幻觉。 - Note that due to the challenging nature of the task, LLMs are likely to hallucinate when they have no knowledge or context regarding the question. + 请注意,由于任务的挑战性,当 LLM 对问题没有知识或背景时,它们可能会产生幻觉。 -该 prompt 已经进行了一些修改,以包括指示符,显示 prompt 的哪些部分对应什么信息。 +该提示稍作修改,包含指示符以显示提示的各部分对应哪些信息。 -## Prompt +## 提示 ```markdown -Patient’s facts: -- 20 year old female -- with a history of anerxia nervosa and depression -- blood pressure 100/50, pulse 50, height 5’5’’ -- referred by her nutrionist but is in denial of her illness -- reports eating fine but is severely underweight +患者情况: +- 20 岁女性 +- 有神经性厌食症和抑郁症病史 +- 血压 100/50,脉搏 50,身高 5’5’’ +- 由她的营养师转诊,但否认自己有病 +- 报告进食正常,但严重体重不足 -Question: Please rewrite the data above into a medical note, using exclusively the information above. +问题:请将上述数据重新写成一份病历记录,只使用以上信息。 -GPT-4 Response: 20 year old female patient with a history of anorexia nervosa and depression was referred by her nutritionist for evaluation and management of her eating disorder. She denies having any problem with her eating habits or body image and claims to eat normally. However, she is severely underweight for her height (BMI 16.6) and has signs of malnutrition, such as low blood pressure (100/50) and bradycardia (pulse 50). She also reports feeling depressed and hopeless. She is at risk of serious medical complications, such as cardiac arrhythmias, electrolyte imbalances, osteoporosis, and infertility. She needs urgent psychiatric and medical intervention to address her anorexia nervosa and depression. +GPT-4 回答:20 岁女性患者,有神经性厌食症和抑郁症病史,由她的营养师转诊以评估和管理她的饮食失调。她否认自己在饮食习惯或身体形象方面有任何问题,并声称吃得正常。然而,她的体重严重不足(BMI 16.6),并有营养不良的迹象,如低血压(100/50)和心动过缓(脉搏 50)。她还报告感到抑郁和绝望。她有严重医学并发症的风险,如心律失常、电解质失衡、骨质疏松和不孕。她需要紧急的精神和医学干预来处理她的神经性厌食症和抑郁症。 -Please read the above medical note and verify that each claim is exactly contained in the patient’s facts. Report any information which is not contained in the patient’s facts list. +请阅读以上病历记录,并核实每个陈述是否完全包含在患者情况中。报告任何不包含在患者情况列表中的信息。 ``` -## Code / API +## 代码 / API ```python from openai import OpenAI - client = OpenAI() + client = OpenAI () - response = client.chat.completions.create( + response = client.chat.completions.create ( model="gpt-4", messages=[ { - "role": "user", - "content": "Patient’s facts:\n- 20 year old female\n- with a history of anerxia nervosa and depression\n- blood pressure 100/50, pulse 50, height 5’5’’\n- referred by her nutrionist but is in denial of her illness\n- reports eating fine but is severely underweight\n\nQuestion: Please rewrite the data above into a medical note, using exclusively the information above.\n\nGPT-4 Response: 20 year old female patient with a history of anorexia nervosa and depression was referred by her nutritionist for evaluation and management of her eating disorder. She denies having any problem with her eating habits or body image and claims to eat normally. However, she is severely underweight for her height (BMI 16.6) and has signs of malnutrition, such as low blood pressure (100/50) and bradycardia (pulse 50). She also reports feeling depressed and hopeless. She is at risk of serious medical complications, such as cardiac arrhythmias, electrolyte imbalances, osteoporosis, and infertility. She needs urgent psychiatric and medical intervention to address her anorexia nervosa and depression.\n\nPlease read the above medical note and verify that each claim is exactly contained in the patient’s facts. Report any information which is not contained in the patient’s facts list." + "role": "user", + "content": "Patient’s facts:\n- 20 year old female\n- with a history of anerxia nervosa and depression\n- blood pressure 100/50, pulse 50, height 5’5’’\n- referred by her nutrionist but is in denial of her illness\n- reports eating fine but is severely underweight\n\nQuestion: Please rewrite the data above into a medical note, using exclusively the information above.\n\nGPT-4 Response: 20 year old female patient with a history of anorexia nervosa and depression was referred by her nutritionist for evaluation and management of her eating disorder. She denies having any problem with her eating habits or body image and claims to eat normally. However, she is severely underweight for her height (BMI 16.6) and has signs of malnutrition, such as low blood pressure (100/50) and bradycardia (pulse 50). She also reports feeling depressed and hopeless. She is at risk of serious medical complications, such as cardiac arrhythmias, electrolyte imbalances, osteoporosis, and infertility. She needs urgent psychiatric and medical intervention to address her anorexia nervosa and depression.\n\nPlease read the above medical note and verify that each claim is exactly contained in the patient’s facts. Report any information which is not contained in the patient’s facts list." } ], temperature=1, @@ -50,7 +50,7 @@ Please read the above medical note and verify that each claim is exactly contain top_p=1, frequency_penalty=0, presence_penalty=0 - ) + ) ``` @@ -58,12 +58,12 @@ Please read the above medical note and verify that each claim is exactly contain ```python import fireworks.client fireworks.client.api_key = "" - completion = fireworks.client.ChatCompletion.create( + completion = fireworks.client.ChatCompletion.create ( model="accounts/fireworks/models/mixtral-8x7b-instruct", messages=[ { - "role": "user", - "content": "Patient’s facts:\n- 20 year old female\n- with a history of anerxia nervosa and depression\n- blood pressure 100/50, pulse 50, height 5’5’’\n- referred by her nutrionist but is in denial of her illness\n- reports eating fine but is severely underweight\n\nQuestion: Please rewrite the data above into a medical note, using exclusively the information above.\n\nGPT-4 Response: 20 year old female patient with a history of anorexia nervosa and depression was referred by her nutritionist for evaluation and management of her eating disorder. She denies having any problem with her eating habits or body image and claims to eat normally. However, she is severely underweight for her height (BMI 16.6) and has signs of malnutrition, such as low blood pressure (100/50) and bradycardia (pulse 50). She also reports feeling depressed and hopeless. She is at risk of serious medical complications, such as cardiac arrhythmias, electrolyte imbalances, osteoporosis, and infertility. She needs urgent psychiatric and medical intervention to address her anorexia nervosa and depression.\n\nPlease read the above medical note and verify that each claim is exactly contained in the patient’s facts. Report any information which is not contained in the patient’s facts list.", + "role": "user", + "content": "Patient’s facts:\n- 20 year old female\n- with a history of anerxia nervosa and depression\n- blood pressure 100/50, pulse 50, height 5’5’’\n- referred by her nutrionist but is in denial of her illness\n- reports eating fine but is severely underweight\n\nQuestion: Please rewrite the data above into a medical note, using exclusively the information above.\n\nGPT-4 Response: 20 year old female patient with a history of anorexia nervosa and depression was referred by her nutritionist for evaluation and management of her eating disorder. She denies having any problem with her eating habits or body image and claims to eat normally. However, she is severely underweight for her height (BMI 16.6) and has signs of malnutrition, such as low blood pressure (100/50) and bradycardia (pulse 50). She also reports feeling depressed and hopeless. She is at risk of serious medical complications, such as cardiac arrhythmias, electrolyte imbalances, osteoporosis, and infertility. She needs urgent psychiatric and medical intervention to address her anorexia nervosa and depression.\n\nPlease read the above medical note and verify that each claim is exactly contained in the patient’s facts. Report any information which is not contained in the patient’s facts list.", } ], stop=["<|im_start|>","<|im_end|>","<|endoftext|>"], @@ -80,9 +80,7 @@ Please read the above medical note and verify that each claim is exactly contain ) ``` - - ## 参考 -- [人工通用智能的曙光: GPT-4 的早期实验](https://arxiv.org/abs/2303.12712) (13 April 2023) \ No newline at end of file +- [人工通用智能的曙光:GPT-4 的早期实验](https://arxiv.org/abs/2303.12712) (2023 年 4 月 13 日) \ No newline at end of file