Compare commits

...

17 Commits

Author SHA1 Message Date
Elvis Saravia 77d161620f
Merge pull request #463 from behrends/llm_in_context_et_al
llm in-context recall, mixtral 8x22b, llama3, rag-faithfulness (German translation)
3 weeks ago
Elvis Saravia e83876b0e9
Merge pull request #464 from tgrandguillotte/patch-2
Tree of Thoughts page French translation
3 weeks ago
Elvis Saravia 3585ecf7e4
Merge pull request #469 from WayneCui/main
add pages>research>groq.zh.mdx
3 weeks ago
Elvis Saravia 2b7f108797
Merge pull request #470 from DarthReidar-jp/patch-1
Add Japanese translation for prompt_chaining
3 weeks ago
Elvis Saravia 3cf69b1dc8
Merge pull request #471 from DarthReidar-jp/main
Add Japanese translation for reflexion
3 weeks ago
Elvis Saravia e9f7159fb5
Merge pull request #472 from kaustubhdhole/patch-1
Update rag.en.mdx with rag simulators
3 weeks ago
Kaustubh Dhole 50b15ca3b9
Update rag.en.mdx with rag simulators 3 weeks ago
DarthReidar df8bb3e282
Add Japanese translation for reflexion
This commit adds the Japanese translation for the documentation on reflexion. The file updated is `reflexion.jp.mdx`, ensuring the content is accessible to Japanese-speaking developers and users. This translation aims to enhance understanding and usage of prompt chaining techniques within the Japanese developer community.
3 weeks ago
DarthReidar f5f7a8a739
Add Japanese translation for prompt_chaining [Update prompt_chaining.jp.mdx]
This commit adds the Japanese translation for the documentation on prompt chaining. 
The file updated is `prompt_chaining.jp.mdx`, ensuring the content is accessible to Japanese-speaking developers and users. This translation aims to enhance understanding and usage of prompt chaining techniques within the Japanese developer community.
3 weeks ago
cuiw 31c64dbf7a add pages>research>groq.zh.mdx 3 weeks ago
Tommy G ceacb9b354
Tree of Thoughts page French translation 1 month ago
Erik Behrends c25f5173a0 rag-faithfulness 1 month ago
Erik Behrends 82a7592ece llama3 (German) 1 month ago
Erik Behrends 487f338403 llm setting video 1 month ago
Erik Behrends aa6a7a9da6 mixtral 8x22b 1 month ago
Erik Behrends e1b55f16c7 update (German translation) 1 month ago
Erik Behrends 51811197b6 llm in-context recall (German translation) 1 month ago

@ -1,5 +1,15 @@
# LLM Einstellungen
import {Bleed} from 'nextra-theme-docs'
<Bleed>
<iframe width="100%"
height="415px"
src="https://www.youtube.com/embed/CB0H7esOl68?si=OECAnvgnvJHy0qZ2" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
allowFullScreen
/>
</Bleed>
Beim Entwerfen und Testen von Prompts interagieren Sie normalerweise über eine API mit dem LLM. Sie können einige Parameter konfigurieren, um unterschiedliche Ergebnisse für Ihre Prompts zu erhalten. Das Anpassen dieser Einstellungen ist wichtig, um die Zuverlässigkeit und Erwünschtheit der Antworten zu verbessern, und es bedarf des Experimentierens, um die richtigen Einstellungen für Ihre Anwendungsfälle herauszufinden. Unten finden Sie die gängigen Einstellungen, auf die Sie bei der Verwendung verschiedener LLM-Anbieter stoßen werden:
**Temperatur** - Kurz gesagt, je niedriger die `temperature`, desto deterministischer sind die Ergebnisse in dem Sinne, dass immer das wahrscheinlichste nächste Token gewählt wird. Eine Erhöhung der Temperatur kann zu mehr Zufälligkeit führen und damit vielfältigere oder kreativere Ausgaben fördern. Sie erhöhen im Grunde das Gewicht der anderen möglichen Tokens. Im Hinblick auf die Anwendung möchten Sie vielleicht einen niedrigeren Temperaturwert für Aufgaben wie faktenbasierte QA verwenden, um präzisere und knappere Antworten zu fördern. Für die Generierung von Gedichten oder andere kreative Aufgaben könnte es vorteilhaft sein, den Temperaturwert zu erhöhen.

@ -10,9 +10,11 @@
"gpt-4": "GPT-4",
"grok-1": "Grok-1",
"llama": "LLaMA",
"llama-3": "Llama 3",
"mistral-7b": "Mistral 7B",
"mistral-large": "Mistral Large",
"mixtral": "Mixtral",
"mixtral-8x22b": "Mixtral 8x22B",
"olmo": "OLMo",
"phi-2": "Phi-2",
"sora": "Sora",

@ -0,0 +1,49 @@
# Llama 3
import {Bleed} from 'nextra-theme-docs'
Meta hat kürzlich ihre neue Familie großer Sprachmodelle (LLMs), genannt Llama 3, [vorgestellt](https://llama.meta.com/llama3/). Diese Veröffentlichung umfasst vorab trainierte und anweisungsoptimierte Modelle mit 8 Milliarden und 70 Milliarden Parametern.
## Architekturdetails zu Llama 3
Hier eine Zusammenfassung der technischen Details von Llama 3:
- Es verwendet einen standardmäßigen Decoder-only-Transformer.
- Der Wortschatz umfasst 128K Token.
- Es wird auf Sequenzen von 8K Token trainiert.
- Es wendet gruppierte Abfrageaufmerksamkeit (GQA) an.
- Es ist auf über 15T Token vorab trainiert.
- Es beinhaltet eine Nachtrainierung, die eine Kombination aus SFT, Ablehnungs-Stichprobenentnahme, PPO und DPO einschließt.
## Leistung
Auffällig ist, dass Llama 3 8B (anweisungsoptimiert) [Gemma 7B](https://www.promptingguide.ai/models/gemma) und [Mistral 7B Instruct](https://www.promptingguide.ai/models/mistral-7b) übertrifft. Llama 3 70 übertrifft deutlich [Gemini Pro 1.5](https://www.promptingguide.ai/models/gemini-pro) und [Claude 3 Sonnet](https://www.promptingguide.ai/models/claude-3), bleibt jedoch beim MATH-Benchmark etwas hinter Gemini Pro 1.5 zurück.
!["Llama 3 Leistung"](../../img/llama3/llama-instruct-performance.png)
*Quelle: [Meta AI](https://ai.meta.com/blog/meta-llama-3/)*
Die vorab trainierten Modelle übertreffen ebenfalls andere Modelle bei mehreren Benchmarks wie AGIEval (Englisch), MMLU und Big-Bench Hard.
!["Llama 3 Leistung"](../../img/llama3/llama3-pretrained-results.png)
*Quelle: [Meta AI](https://ai.meta.com/blog/meta-llama-3/)*
## Llama 3 400B
Meta berichtete auch, dass sie ein Modell mit 400 Milliarden Parametern veröffentlichen werden, das derzeit noch trainiert wird und bald verfügbar sein soll! Es gibt auch Bemühungen um multimodale Unterstützung, mehrsprachige Fähigkeiten und längere Kontextfenster. Der aktuelle Checkpoint für Llama 3 400B (Stand 15. April 2024) liefert die folgenden Ergebnisse bei gängigen Benchmarks wie MMLU und Big-Bench Hard:
!["Llama 3 400B"](../../img/llama3/llama-400b.png)
*Quelle: [Meta AI](https://ai.meta.com/blog/meta-llama-3/)*
Die Lizenzinformationen für die Llama 3 Modelle können auf der [Modellkarte](https://github.com/meta-llama/llama3/blob/main/MODEL_CARD.md) gefunden werden.
## Ausführliche Bewertung von Llama 3
Hier folgt eine längere Bewertung von Llama 3:
<Bleed>
<iframe width="100%"
height="415px"
src="https://www.youtube.com/embed/h2aEmciRd6U?si=m7-xXu5IWpB-6mE0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
allowFullScreen
/>
</Bleed>

@ -0,0 +1,28 @@
# Mixtral 8x22B
Mixtral 8x22B ist ein neues offenes großes Sprachmodell (LLM), das von Mistral AI veröffentlicht wurde. Mixtral 8x22B wird als sparsames Mischmodell aus Experten charakterisiert, mit 39 Milliarden aktiven Parametern aus insgesamt 141 Milliarden Parametern.
## Fähigkeiten
Mixtral 8x22B wurde entwickelt, um ein kosteneffizientes Modell zu sein, mit Fähigkeiten, die mehrsprachiges Verständnis, mathematisches Denken, Codegenerierung, native Funktionsaufrufunterstützung und eingeschränkte Ausgabeunterstützung umfassen. Das Modell unterstützt eine Kontextfenstergröße von 64000 (64K) Token, was eine leistungsstarke Informationsabrufung bei großen Dokumenten ermöglicht.
Mistral AI behauptet, dass Mixtral 8x22B eines der besten Leistungs-Kosten-Verhältnisse unter den Community-Modellen bietet und aufgrund seiner sparsamen Aktivierungen deutlich schnell ist.
!["Mixtral 8x22B Leistung"](../../img/mixtral/mixtral-8-cost.png)
*Quelle: [Mistral AI Blog](https://mistral.ai/news/mixtral-8x22b/)*
## Ergebnisse
Gemäß den [offiziell berichteten Ergebnissen](https://mistral.ai/news/mixtral-8x22b/) übertrifft Mixtral 8x22B (mit 39 Milliarden aktiven Parametern) andere Spitzenmodelle wie Command R+ und Llama 2 70B in mehreren Denk- und Wissensbenchmarks wie MMLU, HellaS, TriQA, NaturalQA unter anderen.
!["Mixtral 8x22B Denk- und Wissensleistung"](../../img/mixtral/mixtral-8-reasoning.png)
*Quelle: [Mistral AI Blog](https://mistral.ai/news/mixtral-8x22b/)*
Mixtral 8x22B übertrifft alle offenen Modelle bei Programmier- und Mathematikaufgaben, wenn es anhand von Benchmarks wie GSM8K, HumanEval und Math bewertet wird. Es wird berichtet, dass Mixtral 8x22B Instruct eine Punktzahl von 90% auf GSM8K (maj@8) erreicht.
!["Mixtral 8x22B Denk- und Wissensleistung"](../../img/mixtral/mixtral-8-maths.png)
*Quelle: [Mistral AI Blog](https://mistral.ai/news/mixtral-8x22b/)*
Weitere Informationen zu Mixtral 8x22B und dessen Nutzung finden Sie hier: https://docs.mistral.ai/getting-started/open_weight_models/#operation/listModels
Das Modell wird unter einer Apache 2.0-Lizenz veröffentlicht.

@ -2,6 +2,8 @@
"llm-agents": "LLM Agenten",
"rag": "RAG für LLMs",
"llm-reasoning": "LLM Reasoning",
"rag-faithfulness": "RAG Zuverlässigkeit",
"llm-recall": "LLM In-Context Recall",
"thoughtsculpt": "ThoughtSculpt",
"infini-attention": "Infini-Attention",
"trustworthiness-in-llms": "Vertrauenswürdigkeit in LLMs",

@ -0,0 +1,21 @@
# Groq 是什么?
[Groq](https://groq.com/) 最近因其作为当今最快的大型语言模型LLM推理解决方案之一而广受关注。LLM 实践者对于降低LLM响应的延迟非常感兴趣因为延迟是一个重要的性能指标它需要被优化以支持实时人工智能应用。目前许多公司都在LLM推理领域展开竞争。
Groq 是那些声称在 [Anyscale 的 LLMPerf 排行榜](https://github.com/ray-project/llmperf-leaderboard)上,比其他顶尖的基于云的服务提供商快 18 倍的公司之一。Groq 目前通过其 API 提供了 Meta AI 的 Llama 2 70B 和 Mixtral 8x7B 等模型。这些模型由 Groq LPU™ 推理引擎驱动,该引擎是基于他们为运行 LLM 特别设计的定制硬件——语言处理单元LPUs构建的。
根据 Groq 的常见问题解答LPU 有助于减少每个单词的计算时间,从而加快文本序列的生成。您可以在他们获得 ISCA 奖项的 [2020 年](https://wow.groq.com/groq-isca-paper-2020/)和 [2022 年](https://wow.groq.com/isca-2022-paper/) 的论文中,阅读有关 LPU 技术细节及其优势的更多信息。
以下是一张展示了他们模型的速度和定价的图表:
!["Groq 定价"](../../img/research/groq.png)
下面的图表比较了输出词元吞吐量Output Tokens Throughput词元/秒),这是衡量每秒返回的平均输出词元数的指标。图表中的数字代表了基于 150 个请求的 Llama 2 70B 模型上LLM 推理服务提供商的平均输出词元吞吐量。
!["LLMPerf 排行榜"](https://github.com/ray-project/llmperf-leaderboard/blob/main/.assets/output_tokens_per_s.jpg?raw=true)
对于流媒体应用而言LLM 推理的另一个重要因素是首个词元时间Time to First TokenTTFT它指的是 LLM 返回第一个词元所需的时间。以下图表展示了不同 LLM 推理服务提供商在这方面的表现:
!["首个词元时间(秒)"](https://github.com/ray-project/llmperf-leaderboard/blob/main/.assets/ttft.jpg?raw=true)
您可以在[此处](https://wow.groq.com/groq-lpu-inference-engine-crushes-first-public-llm-benchmark/) 阅读有关 Groq 在 Anyscale 的 LLMPerf 排行榜上的 LLM 推理性能的更多信息。

@ -0,0 +1,26 @@
# LLM In-Context Recall hängt vom Prompt ab
import {Bleed} from 'nextra-theme-docs'
<Bleed>
<iframe width="100%"
height="415px"
src="https://www.youtube.com/embed/2cNO76lIZ4s?si=tbbdo-vnr56YQ077" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
allowFullScreen
/>
</Bleed>
Dieses neue [Paper von Machlab und Battle (2024)](https://arxiv.org/abs/2404.08865) analysiert die In-Context Recall-Leistung verschiedener LLMs anhand mehrerer Nadel-im-Heuhaufen-Tests.
Es zeigt, dass verschiedene LLMs Fakten auf unterschiedlichen Längen und in verschiedener Tiefe erinnern. Es stellt fest, dass die Recall-Leistung eines Modells erheblich durch kleine Änderungen im Prompt beeinflusst wird.
!["Needle In the HayStack Performance"](../../img/research/haystack-performance.png)
*Quelle: [Machlab und Battle (2024)](https://arxiv.org/abs/2404.08865)*
Darüber hinaus kann das Zusammenspiel zwischen Prompt-Inhalt und Trainingsdaten die Antwortqualität verschlechtern.
Die Recall-Fähigkeit eines Modells kann durch Vergrößerung, Verbesserung des Attention-Mechanismus, das Ausprobieren verschiedener Trainingsstrategien und das Anwenden von Fine-Tuning verbessert werden.
Wichtiger praktischer Tipp aus dem Paper: „Die fortlaufende Bewertung wird die Auswahl von LLMs für individuelle Anwendungsfälle weiter informieren, ihre Wirkung und Effizienz in realen Anwendungen maximieren, da die Technologie weiterhin fortschreitet.“
Die wichtigsten Erkenntnisse aus diesem Paper sind die Bedeutung einer sorgfältigen Gestaltung des Prompts, die Einrichtung eines kontinuierlichen Bewertungsprotokolls und das Testen verschiedener Modellverbesserungsstrategien, um Recall und Nutzen zu verbessern.

@ -0,0 +1,26 @@
# Wie zuverlässig sind RAG-Modelle?
import {Bleed} from 'nextra-theme-docs'
<Bleed>
<iframe width="100%"
height="415px"
src="https://www.youtube.com/embed/eEU1dWVE8QQ?si=b-qgCU8nibBCSX8H" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
allowFullScreen
/>
</Bleed>
Dieses neue Paper von [Wu et al. (2024)](https://arxiv.org/abs/2404.10198) zielt darauf ab, das Kräftemessen zwischen den RAG-Modellen und der internen Priorisierung von LLMs zu quantifizieren.
Es konzentriert sich dabei auf GPT-4 und andere LLMs bei der Beantwortung von Fragen zur Analyse.
Es wurde festgestellt, dass das Bereitstellen korrekter abgerufener Informationen die meisten Fehler des Modells korrigiert (94% Genauigkeit).
!["RAG Treue"](../../img/research/rag-faith.png)
*Quelle: [Wu et al. (2024)](https://arxiv.org/abs/2404.10198)*
Wenn die Dokumente mehr falsche Werte enthalten und das interne Priorisieren des LLM schwach ist, neigt das LLM eher dazu, falsche Informationen wiederzugeben. Es wurde jedoch festgestellt, dass die LLMs widerstandsfähiger sind, wenn sie eine stärkere Vorprägung haben.
Das Paper berichtet auch, dass „je mehr die modifizierte Information von der Vorprägung des Modells abweicht, desto unwahrscheinlicher ist es, dass das Modell sie bevorzugt.“
Viele Entwickler und Unternehmen setzen RAG-Systeme in der Produktion ein. Diese Arbeit hebt die Bedeutung der Risikobewertung bei der Verwendung von LLMs hervor, die verschiedene Arten von Kontextinformationen enthalten können, die unterstützende, widersprüchliche oder völlig inkorrekte Informationen enthalten können.

@ -188,6 +188,7 @@ Below is a collection of research papers highlighting key insights and the lates
| **Insight** | **Reference** | **Date** |
| ------------- | ------------- | ------------- |
| Shows how retrieval augmentation can be used to distill language model assistants by training retrieval augmented simulators | [KAUCUS: Knowledge Augmented User Simulators for Training Language Model Assistants](https://aclanthology.org/2024.scichat-1.5)| Mar 2024 |
| Proposes Corrective Retrieval Augmented Generation (CRAG) to improve the robustness of generation in a RAG system. The core idea is to implement a self-correct component for the retriever and improve the utilization of retrieved documents for augmenting generation. The retrieval evaluator helps to assess the overall quality of retrieved documents given a query. Using web search and optimized knowledge utilization operations can improve automatic self-correction and efficient utilization of retrieved documents. | [Corrective Retrieval Augmented Generation](https://arxiv.org/abs/2401.15884)| Jan 2024|
| Recursively embeds, clusters, and summarizes chunks of text, constructing a tree with differing levels of summarization from the bottom up. At inference time, the proposed RAPTOR model retrieves from the tree, integrating information across lengthy documents at different levels of abstraction. | [RAPTOR: Recursive Abstractive Processing for Tree-Organized Retrieval](https://arxiv.org/abs/2401.18059)| Jan 2024 |
| A general program with multi-step interactions between LMs and retrievers to efficiently tackle multi-label classification problems. | [In-Context Learning for Extreme Multi-Label Classification](https://arxiv.org/abs/2401.12178) | Jan 2024 |
@ -242,6 +243,7 @@ Below is a collection of research papers highlighting key insights and the lates
## References
- [KAUCUS: Knowledge Augmented User Simulators for Training Language Model Assistants](https://aclanthology.org/2024.scichat-1.5)
- [A Survey on Hallucination in Large Language Models: Principles,Taxonomy, Challenges, and Open Questions](https://arxiv.org/abs/2311.05232)
- [Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks](https://arxiv.org/abs/2005.11401)
- [Retrieval-augmented multimodal language modeling](https://arxiv.org/abs/2211.12561)
@ -257,4 +259,4 @@ Below is a collection of research papers highlighting key insights and the lates
- [Best Practices for LLM Evaluation of RAG Applications](https://www.databricks.com/blog/LLM-auto-eval-best-practices-RAG)
- [Building Production-Ready RAG Applications](https://youtu.be/TRjq7t2Ms5I?si=gywRj82NIc-wsHcF)
- [Evaluating RAG Part I: How to Evaluate Document Retrieval](https://www.deepset.ai/blog/rag-evaluation-retrieval)
- [Retrieval Augmented Generation meets Reciprocal Rank Fusion and Generated Queries](https://towardsdatascience.com/forget-rag-the-future-is-rag-fusion-1147298d8ad1)
- [Retrieval Augmented Generation meets Reciprocal Rank Fusion and Generated Queries](https://towardsdatascience.com/forget-rag-the-future-is-rag-fusion-1147298d8ad1)

@ -1,3 +1,105 @@
# Prompt Chaining
This page needs a translation! Feel free to contribute a translation by clicking the `Edit this page` button on the right side.
import {Screenshot} from 'components/screenshot'
import PC1 from '../../img/prompt_chaining/prompt-chaining-1.png'
## プロンプトチェイニングの紹介
LLMの信頼性と性能を向上させるために、重要な手法の一つとして、タスクを複数のサブタスクに分割することがあります。これらのサブタスクが特定されると、LLMはそれぞれに対してプロンプトを出し、その回答を次のプロンプトの入力として利用します。これをプロンプト・チェイニングと呼び、タスクをサブタスクに分割してプロンプトの連鎖を作ることが目的です。
この方法は、LLMが一度に扱うには複雑すぎる詳細なプロンプトに対処する際に有効です。プロンプトを連鎖させることで、望ましい最終結果に到達する前に、生成された応答に対して変更や追加の処理を行うことができます。プロンプトの連鎖はパフォーマンスを向上させるだけでなく、LLMアプリケーションの透明性を高め、より良い制御性と信頼性を実現するのに役立ちます。これにより、モデルの応答に関する問題を簡単にデバッグし、改善が必要な各段階のパフォーマンスを分析して改善することが可能になります。特に、LLMを使った会話アシスタントを構築し、アプリケーションのパーソナライズとユーザーエクスペリエンスを向上させる際にプロンプト・チェイニングは有効です。
## プロンプト・チェイニングの使用例
### ドキュメントQAのためのプロンプト・チェイニング
プロンプト・チェイニングは、さまざまな操作や変換を伴うシナリオで利用可能です。例として、LLMの一般的な用途のひとつに、長い文章に基づいた質問に答えることがあります。
ここで2つの異なるプロンプトを用意します。最初のプロンプトは、関連する引用を抽出して質問に答えるためのもので、次のプロンプトは、抽出された引用と元のドキュメントを使って質問に答えます。つまり、2つのステップを経て、ドキュメントにおける質問に対する回答を得ることが目的です。
以下の最初のプロンプト例では、質問に基づいてドキュメントから関連する引用を抽出するよう設計されています。簡潔さを保つために、文書のプレースホルダーを設定しています。このプロンプトを試す場合は、ウィキペディアの記事をコピー&ペーストし、このページで[プロンプトエンジニアリング](https://en.wikipedia.org/wiki/Prompt_engineering)を適用してみてくださいこのタスクには広範なコンテキストが必要なため、OpenAIの`gpt-4-1106-preview`モデルを使用します。このプロンプトは、Claudeのような長いコンテキストを扱うLLMでも使用可能です。
プロンプト1
```
あなたは親切なアシスタントです。
あなたの仕事は、文書で与えられた質問に答えるのを助けることです。最初のステップは、####で区切られた文書から質問に関連する引用を抽出することです。
引用のリストは<quotes></quotes>を使って出力してください。関連する引用が見つからなかった場合は「関連する引用は見つかりませんでした。]と返信してください。
####
{{document}}
####
```
これは、`user`のroleを使用して渡される質問を含むプロンプト全体のスクリーンショットです。
<Screenshot src={PC1} alt="Prompt Chaining Part 1" />
Output of Prompt 1:
```
<quotes>
- Chain-of-thought (CoT) prompting[27]
- Generated knowledge prompting[37]
- Least-to-most prompting[38]
- Self-consistency decoding[39]
- Complexity-based prompting[41]
- Self-refine[42]
- Tree-of-thought prompting[43]
- Maieutic prompting[45]
- Directional-stimulus prompting[46]
- Textual inversion and embeddings[59]
- Using gradient descent to search for prompts[61][62][63][64]
- Prompt injection[65][66][67]
</quotes>
```
最初のプロンプトで得られた引用は、次に示す2番目のプロンプトの入力として使用できます。引用をもう少し整理することもできます。つまり、引用部分から出典を取り除くことが可能です。これらの出典は削除するか、別のプロンプトの一部として活用することができますが、現段階では無視しても構いません。
次に、2番目のプロンプトは、プロンプト1で抽出された関連する引用を取り、文書で提起された質問と抽出された引用に対して有益な回答を準備します。
2番目のプロンプトは以下のようになります
```
ある文書から抽出された関連する引用(<quotes></quotes>で区切られています)と元の文書(###で区切られています)が与えられたら、質問に対する答えを作成してください。
回答は正確で、友好的な口調で、役に立つように聞こえるようにしてください。
####
{{document}}
####
<quotes>
- Chain-of-thought (CoT) prompting[27]
- Generated knowledge prompting[37]
- Least-to-most prompting[38]
- Self-consistency decoding[39]
- Complexity-based prompting[41]
- Self-refine[42]
- Tree-of-thought prompting[43]
- Maieutic prompting[45]
- Directional-stimulus prompting[46]
- Textual inversion and embeddings[59]
- Using gradient descent to search for prompts[61][62][63][64]
- Prompt injection[65][66][67]
</quotes>
```
Output of Prompt 2:
```
文書で言及されているプロンプトのテクニックには、以下のようなものがある:
1. Chain-of-thought (CoT) prompting[27]
2. Generated knowledge prompting[37]
3. Least-to-most prompting[38]
4. Self-consistency decoding[39]
5. Complexity-based prompting[41]
6. Self-refine[42]
7. Tree-of-thought prompting[43]
8. Maieutic prompting[45]
9. Directional-stimulus prompting[46]
10. Textual inversion and embeddings[59]
11. Using gradient descent to search for prompts[61][62][63][64]
12. Prompt injection[65][66][67]
これらの技法はそれぞれ、大規模な言語モデルとの相互作用を強化したり特定したりして、望ましい結果を生み出すための独自の戦略を採用している。
```
おわかりのように、プロンプトチェーンを簡略化して作成することは、応答 がいくつかの操作や変換を受ける必要がある場合に有効なプロンプトアプローチである。練習として、アプリケーションのユーザーに最終的なレスポンスとして送信する前に、レスポンスから引用 (例: 27) を削除するプロンプトを自由に設計してください。
プロンプトチェイニングの例は、こちらの [documentation](https://docs.anthropic.com/claude/docs/prompt-chaining) ( Claude LLMを活用しています)にもあります。私たちの例は彼らの例からヒントを得てアレンジしたものです。

@ -1,3 +1,71 @@
# Reflexion
This page needs a translation! Feel free to contribute a translation by clicking the `Edit this page` button on the right.
リフレクションは、言語的フィードバックを通じて言語ベースのエージェントを強化するためのフレームワークです。[Shinn et al. (2023)](https://arxiv.org/pdf/2303.11366.pdf)によると、「リフレクションは、エージェントの記憶エンコーディングとLLMパラメータの選択をパラメータ化することにより、“言葉による”強化を行う新しいパラダイムです。」
概念的には、リフレクションは環境からのフィードバック自由形式の言語またはスカラーを言語的フィードバックに変換し、これを自己反省とも呼ばれるものとして次のエピソードでLLMエージェントのコンテキストとして提供します。これにより、エージェントは過去の間違いから迅速かつ効果的に学び、多くの高度なタスクでのパフォーマンスが向上します。
!["Reflexion Framework"](../../img/research/reflexion.png)
図に示されているように、リフレクションは三つの異なるモデルで構成されています:
- **アクター**: 状態観測に基づいてテキストと行動を生成します。アクターは環境で行動を取り、観測を受け取り、それによって軌跡が生成されます。アクターモデルとしては[Chain-of-Thought (CoT)](https://www.promptingguide.ai/techniques/cot)と [ReAct](https://www.promptingguide.ai/techniques/react) が使用されます。また、追加のコンテキストをエージェントに提供するために記憶コンポーネントも加えられています。
- **評価者**: アクターが生成した出力を採点します。具体的には、生成された軌跡短期記憶とも表されるを入力として受け取り、報酬スコアを出力します。タスクに応じて異なる報酬関数が使用されます意思決定タスクにはLLMやルールベースのヒューリスティックが使用されます
- **自己反省**: 自己改善を支援するための言語的強化の手がかりを生成します。この役割はLLMによって達成され、将来の試行に対する貴重なフィードバックを提供します。具体的かつ関連性のあるフィードバックを生成するために、自己反省モデルは報酬シグナル、現在の軌跡、および持続的な記憶を活用します。これらの経験長期記憶に保存されたものは、エージェントが意思決定を迅速に改善するために活用されます。
要約すると、リフレクションプロセスの主要なステップは、a) タスクを定義する、b) 軌跡を生成する、c) 評価する、d) 反省を行う、e) 次の軌跡を生成する、です。下の図は、リフレクションエージェントが意思決定、プログラミング、推論など様々なタスクを解決するために行動を反復的に最適化する方法の例を示しています。リフレクションは自己評価、自己反省、記憶コンポーネントを導入することでReActフレームワークを拡張します。
!["Reflexion Examples"](../../img/research/reflexion-examples.png)
## Results
実験結果によると、リフレクションエージェントは、意思決定タスクであるAlfWorld、推論問題のHotPotQA、HumanEvalでのPythonプログラミングタスクにおいて、パフォーマンスを大幅に向上させています。
連続的な意思決定タスクAlfWorldで評価されたとき、ReAct + リフレクションは、HeuristicやGPTを用いた二値分類の自己評価技術を使用して、130/134のタスクを完了し、ReActを大幅に上回りました。
!["Reflexion ALFWorld Results"](../../img/research/reflexion-alfworld.png)
リフレクションは、いくつかの学習ステップにわたり、すべてのベースラインアプローチを大きく上回ります。推論のみの場合や、最新の軌跡から成るエピソード記憶を追加した場合、それぞれ、リフレクション + CoTはCoTのみやCoTとエピソード記憶を併用した場合を上回ります。
!["Reflexion ALFWorld Results"](../../img/research/reflexion-hotpotqa.png)
以下の表に要約されているように、リフレクションは、MBPP、HumanEval、Leetcode HardでのPythonおよびRustのコード記述において、以前の最先端アプローチを一般的に上回ります。
!["Reflexion ALFWorld Results"](../../img/research/reflexion-programming.png)
## When to Use Reflexion?
リフレクションは以下の場合に最適です:
1. **エージェントが試行錯誤から学習する必要がある場合**:リフレクションは、過去の間違いを反省し、その知識を将来の決定に取り入れることで、エージェントのパフォーマンスを向上させるよう設計されています。これは、意思決定、推論、プログラミングなど、試行錯誤を通じて学習する必要があるタスクに適しています。
2. **従来の強化学習方法が非現実的な場合**従来の強化学習RL方法は、多くの訓練データや高価なモデルのファインチューニングを必要とすることが多いです。リフレクションは、基盤となる言語モデルのファインチューニングを必要としない軽量な代替手段を提供し、データと計算リソースの面で効率的です。
3. **繊細なフィードバックが必要な場合**リフレクションは言語的フィードバックを利用し、従来のRLで使用されるスカラー報酬よりも繊細で具体的です。これにより、エージェントは自身の間違いをよりよく理解し、次の試行でより的確な改善を行うことができます。
4. **解釈可能性と明示的な記憶が重要な場合**リフレクションは従来のRL方法に比べて、より解釈可能で明示的な形式のエピソード記憶を提供します。エージェントの自己反省はその記憶に保存され、学習プロセスの分析と理解が容易になります。
リフレクションが効果的なタスク:
- **連続的な意思決定**リフレクションエージェントは、さまざまな環境をナビゲートし、複数ステップの目標を達成するAlfWorldタスクでパフォーマンスを向上します。
- **推論**リフレクションは、複数の文書にまたがる推論を必要とする質問回答データセットであるHotPotQAで、エージェントのパフォーマンスを向上させました。
- **プログラミング**リフレクションエージェントは、HumanEvalやMBPPなどのベンチマークでより優れたコードを書き、場合によっては最先端の結果を達成しています。
リフレクションのいくつかの制限:
- **自己評価能力に依存**:リフレクションは、エージェントが自身のパフォーマンスを正確に評価し、有用な自己反省を生成する能力に依存しています。これは、特に複雑なタスクでは困難かもしれませんが、モデルの能力が向上するにつれてリフレクションも時間とともに改善されると期待されます。
- **長期記憶の制約**:リフレクシ
ョンは最大容量のスライディングウィンドウを使用しますが、より複雑なタスクでは、ベクター埋め込みやSQLデータベースなどの高度な構造の使用が有利かもしれません。
- **コード生成の制限**:テスト駆動開発では正確な入出力マッピング(例えば、非決定論的な生成関数やハードウェアに影響を受ける関数の出力など)を指定することに制限があります。
---
*Figures source: [Reflexion: Language Agents with Verbal Reinforcement Learning](https://arxiv.org/pdf/2303.11366.pdf)*
## References
- [Reflexion: Language Agents with Verbal Reinforcement Learning](https://arxiv.org/pdf/2303.11366.pdf)
- [Can LLMs Critique and Iterate on Their Own Outputs?](https://evjang.com/2023/03/26/self-reflection.html)

@ -1,3 +1,45 @@
# Tree of Thoughts (ToT)
This page needs a translation! Feel free to contribute a translation by clicking the `Edit this page` button on the right side.
import { Callout, FileTree } from 'nextra-theme-docs'
import {Screenshot} from 'components/screenshot'
import TOT from '../../img/TOT.png'
import TOT2 from '../../img/TOT2.png'
import TOT3 from '../../img/TOT3.png'
Pour des tâches complexes qui nécessitent une exploration ou une anticipation stratégique, les techniques de prompt traditionnelles ou simples sont insuffisantes. [Yao et al. (2023)](https://arxiv.org/abs/2305.10601) et [Long (2023)](https://arxiv.org/abs/2305.08291) ont récemment proposé "Tree of Thoughts" (ToT), un framework qui généralise le prompt "chain-of-thought" et encourage l'exploration à travers des pensées qui servent d'étapes intermédiaires pour la résolution de problèmes généraux avec des modèles de langage.
ToT maintient un arbre de pensées, où les pensées représentent des séquences de langage cohérentes qui servent d'étapes intermédiaires vers la résolution d'un problème. Cette approche permet à un LLM d'auto-évaluer les progrès à travers les pensées intermédiaires réalisées vers la résolution d'un problème grâce à un processus de raisonnement délibéré. La capacité du LLM à générer et évaluer les pensées est ensuite combinée avec des algorithmes de recherche (par exemple, recherche en largeur et recherche en profondeur) pour permettre une exploration systématique des pensées avec anticipation et retour en arrière.
Le framework ToT est illustré ci-dessous :
<Screenshot src={TOT} alt="TOT" />
Source de l'image : [Yao et al. (2023)](https://arxiv.org/abs/2305.10601)
Lors de l'utilisation de ToT, différentes tâches nécessitent de définir le nombre de candidats et le nombre de pensées/étapes. Par exemple, comme démontré dans l'article, le Jeu des 24 est utilisé comme une tâche de raisonnement mathématique qui nécessite de décomposer les pensées en 3 étapes, chacune impliquant une équation intermédiaire. À chaque étape, les 5 meilleurs candidats sont conservés.
Pour effectuer une recherche en largeur dans ToT pour la tâche du Jeu des 24, le LLM est invité à évaluer chaque candidat de pensée comme "sûr/peut-être/impossible" par rapport à l'objectif d'atteindre 24. Comme l'indiquent les auteurs, "l'objectif est de promouvoir des solutions partielles correctes qui peuvent être jugées dans quelques essais, d'éliminer les solutions partielles impossibles en se basant sur le bon sens 'trop grand/petit', et de garder les 'peut-être'". Les valeurs sont échantillonnées 3 fois pour chaque pensée. Le processus est illustré ci-dessous :
<Screenshot src={TOT2} alt="TOT2" />
Source de l'image : [Yao et al. (2023)](https://arxiv.org/abs/2305.10601)
D'après les résultats rapportés dans la figure ci-dessous, ToT surpasse considérablement les autres méthodes de prompt :
<Screenshot src={TOT3} alt="TOT3" />
Source de l'image : [Yao et al. (2023)](https://arxiv.org/abs/2305.10601)
Code disponible [ici](https://github.com/princeton-nlp/tree-of-thought-llm) et [ici](https://github.com/jieyilong/tree-of-thought-puzzle-solver)
À un niveau plus élevé, les idées principales de [Yao et al. (2023)](https://arxiv.org/abs/2305.10601) et [Long (2023)](https://arxiv.org/abs/2305.08291) sont similaires. Les deux améliorent la capacité des LLM à résoudre des problèmes complexes par la recherche d'arbres via une conversation en plusieurs tours. Une des principales différences est que [Yao et al. (2023)](https://arxiv.org/abs/2305.10601) utilise la recherche via parcours en largeur/profondeur/par faisceaux, tandis que la stratégie de recherche d'arbres (c'est-à-dire quand revenir en arrière et revenir en arrière de combien de niveaux, etc.) proposée dans [Long (2023)](https://arxiv.org/abs/2305.08291) est pilotée par un "Contrôleur ToT" formé par apprentissage par renforcement (RL). La recherche via parcours en largeur/profondeur/par faisceaux sont des stratégies génériques de recherche de solutions sans adaptation à des problèmes spécifiques. En comparaison, un Contrôleur ToT formé par RL pourrait apprendre à partir d'un nouvel ensemble de données ou par auto-apprentissage (AlphaGo vs recherche par force brute), et donc le système ToT basé sur RL peut continuer à évoluer et apprendre de nouvelles connaissances même avec un LLM fixe.
[Hulbert (2023)](https://github.com/dave1010/tree-of-thought-prompting) a proposé le "Tree-of-Thought Prompting", qui applique le concept principal des frameworks ToT comme une technique de prompt simple, amenant le LLM à évaluer les pensées intermédiaires dans un seul prompt. Un exemple de prompt ToT est :
```
Imaginez que trois experts différents répondent à cette question.
Tous les experts écriront 1 étape de leur réflexion,
puis la partageront avec le groupe.
Ensuite, tous les experts passeront à l'étape suivante, etc.
Si un expert se rend compte qu'il a tort à un moment donné, alors il part.
La question est...
```
[Sun (2023)](https://github.com/holarissun/PanelGPT) a évalué le "Tree-of-Thought Prompting" avec des expériences à grande échelle, et introduit PanelGPT --- une idée du prompting avec des tables rondes entre LLM.

@ -1,7 +1,19 @@
# Zero-Shot Prompting
Große LLMs (Language-Modelle) wie beispielsweise GPT-3 sind heute darauf abgestimmt, Anweisungen zu befolgen, und wurden mit großen Datenmengen trainiert. Daher sind sie in der Lage, einige Aufgaben "Zero-Shot" auszuführen.
Wir haben einige Zero-Shot-Beispiele im vorherigen Abschnitt ausprobiert. Hier ist eines der Beispiele, die wir verwendet haben:
import {Bleed} from 'nextra-theme-docs'
<Bleed>
<iframe width="100%"
height="415px"
src="https://www.youtube.com/embed/ZTaHqdkxUMs?si=EDLjgAxuFxFcrSM3" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture"
allowFullScreen
/>
</Bleed>
Große LLMs (Language-Modelle) wie beispielsweise GPT-3.5 Turbo, GPT-4 und Claude 3 sind heute darauf abgestimmt, Anweisungen zu befolgen, und wurden mit großen Datenmengen trainiert. Groß angelegtes Training ermöglicht es diesen Modellen, einige Aufgaben auf
"Zero-Shot"-Weise auszuführen. Zero-Shot-Prompting bedeutet, dass der Prompt, der verwendet wird, um mit dem Modell zu interagieren, keine Beispiele oder Demonstrationen enthält. Der Zero-Shot-Prompt instruiert das Modell direkt, eine Aufgabe ohne zusätzliche Beispiele auszuführen, um es zu lenken.
Wir haben einige Zero-Shot-Beispiele im vorherigen Abschnitt ausprobiert. Hier ist eines der Beispiele, die wir verwendet haben (Text-Klassifizierung):
*Prompt:*
```

Loading…
Cancel
Save