-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
47bffc0
commit ab7b92b
Showing
3 changed files
with
54 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,10 @@ | ||
# LlamaIndex Packs Integration: Ersatz_O1 | ||
# ErsatzO1 Query Engine. | ||
|
||
This module implements the ErsatzO1 approach, combining Chain of Thought (CoT) with | ||
re-reading technique and SELF-CONSISTENCY prompting for generic text input. | ||
|
||
The approach is adapted from the concepts presented in various papers on prompting techniques. | ||
|
||
## Sources | ||
- [Re-Reading Improves Reasoning in Large Language Models](https://arxiv.org/pdf/2309.06275) | ||
- [SELF-CONSISTENCY IMPROVES CHAIN OF THOUGHT REASONING IN LANGUAGE MODELS](https://arxiv.org/pdf/2203.11171) |
26 changes: 26 additions & 0 deletions
26
llama-index-packs/llama-index-packs-ersatz-o1/examples/simple_planing.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import asyncio | ||
|
||
from llama_index.core.llms import LLM | ||
from llama_index.llms.openai import OpenAI | ||
|
||
from llama_index.packs.ersatz_o1 import ErsatzO1QueryEngine | ||
|
||
llm = OpenAI(model="gpt-4-turbo") | ||
|
||
task_context = """ | ||
Every day, Wendi feeds each of her chickens three cups of mixed chicken feed, containing seeds, mealworms and vegetables | ||
to help keep them healthy. She gives the chickens their feed in three separate meals. In the morning, she gives her flock of | ||
chickens 15 cups of feed. In the afternoon, she gives her chickens another 25 cups of feed. | ||
""" | ||
|
||
query_engine = ErsatzO1QueryEngine( | ||
context=task_context, | ||
llm=llm, | ||
reasoning_paths=5, | ||
verbose=True, | ||
) | ||
|
||
if __name__ == "__main__": | ||
res = query_engine.query("How many cups of feed does she need to give her chickens in the final meal of the day if the size of Wendi’s flock is 20 chickens?") | ||
print(res) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters