leo4life2/RALM

★ 3Forks 0PythonGitHub ↗Compare

README

RALM (Retrieval Augmented Language Model)

Based on

Usage

1. Install dependencies

  1. python3 -m venv venv
  2. source venv/bin/activate
  3. pip install -r requirements.txt

2. Set up environment variables

export OPENAI_API_KEY=YOUR_OPENAI_API_KEY

3. Create markdown file for context fetching

Look at data/markdown/froofy_hugger.md or data/markdown/olympics.md for examples. The markdown file MUST have the following structure:

## Title
### Subtitle
Paragraph
### Subtitle
Paragraph
## Title
...

In short, the markdown file must have ## headers and ### subheaders. Text MUST be a single paragraph, and must be under a ### subheader.

4. Create context csv file

python3 md_to_csv.py data/markdown/YOUR_MD_FILE.md OUTPUT_CSV_FILE.csv

5. Run RA-complete code

python3 retrieval_augmented_complete.py CSV_FILE.csv "YOUR_PROMPT_HERE"

Areas for improvement

  • reduce_long simply truncates the text, which is not ideal. Could potentially improve this by summarizing long paragraphs.
  • prompt engineering: refer to the leaked bing chatbot prompts as guidlines
  • need a vector DB for longer contexts.

Contributors

leo4life2

Issues