Skip to content

Commit

Permalink
Docs
Browse files Browse the repository at this point in the history
  • Loading branch information
danielfleischer committed Aug 13, 2024
1 parent 6e1064d commit 7a37d1a
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 14 deletions.
21 changes: 11 additions & 10 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -153,34 +153,35 @@ nav:
- Home:
- Home: "index.md"
- Tutorial: "pubmed.md"
- Data Augmentation: "processing.md"
- Training: "training.md"
- Inference: "inference.md"
- Evaluation: "evaluation.md"
- Guide:
- Data Augmentation: "processing.md"
- Training: "training.md"
- Inference: "inference.md"
- Evaluation: "evaluation.md"
- API:
- Processing:
- Step: "reference/processing/step.md"
- Pipeline: "reference/processing/pipeline.md"
- Utils: "reference/processing/utils.md"
- Dataset Loaders:
- loaders: "reference/processing/dataset_loaders/loaders.md"
- Answer Processors:
- regex: "reference/processing/answer_processors/regex.md"
- Local Steps:
- Common Datasets: "reference/processing/local_steps/common_datasets.md"
- Formatting: "reference/processing/local_steps/formatting.md"
- Retrievers:
- Haystack:
"reference/processing/local_steps/retrievers/haystack.md"
- Context: "reference/processing/local_steps/context.md"
- Prompt Creation: "reference/processing/local_steps/prompter.md"
- RAFT: "reference/processing/local_steps/raft.md"
- API:
- OpenAI Chat:
"reference/processing/local_steps/api/openai.md"
- Context: "reference/processing/local_steps/context.md"
- Prompt Creation: "reference/processing/local_steps/prompter.md"
- RAFT: "reference/processing/local_steps/raft.md"
- Global Steps:
- Sampling and Fewshot: "reference/processing/global_steps/sampling.md"
- Output: "reference/processing/global_steps/output.md"
- Answer Processors:
- regex: "reference/processing/answer_processors/regex.md"
- Utils: "reference/processing/utils.md"
- Models:
- Transformers: "reference/models/hf.md"
- OpenAI: "reference/models/openai_executor.md"
Expand Down
7 changes: 7 additions & 0 deletions ragfoundry/processing/local_steps/api/openai.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ class OpenAIChat(LocalStep):
"""

def __init__(self, model, instruction, prompt_key, answer_key, **kwargs):
"""
Args:
model (dict): Configuration for the OpenAIExecutor.
instruction (str): Path to the system instruction file.
prompt_key (str): Key to the prompt in the item.
answer_key (str): Key to store the response.
"""
super().__init__(**kwargs)

self.model = OpenAIExecutor(**model)
Expand Down
10 changes: 6 additions & 4 deletions ragfoundry/processing/local_steps/prompter.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@
class TextPrompter(LocalStep):
"""
Class for creating prompts. The input is a prompt file with placeholders, a mapping of the placeholders to the item keys, and the key to store the result.
Example: the prompt file is "prompt.txt" with the content "{query}?\n{answer}".
The mapping is {"query": "question", "answer": "solution"}.
The result key is "prompt".
"""

def __init__(self, prompt_file: str, mapping: dict, output_key, **kwargs):
"""
Args:
prompt_file (str): Path to the prompt file.
mapping (dict): Mapping of the placeholders in the prompt to the item keys.
output_key (str): Key to store the formatted prompt.
"""
super().__init__(**kwargs)
self.prompt = open(prompt_file).read()
self.mapping = mapping
Expand Down
3 changes: 3 additions & 0 deletions ragfoundry/processing/step.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ def __call__(self, datasets, **kwargs):
self.process_inputs(datasets, **kwargs)

def process_inputs(self, datasets, **kwargs):
"""
Run the step `process` function for each dataset in `inputs`.
"""
for dataset_name in self.inputs:
self.process(dataset_name, datasets, **kwargs)

Expand Down

0 comments on commit 7a37d1a

Please sign in to comment.