diff --git a/mkdocs.yml b/mkdocs.yml index 876a653..e74feea 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -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" diff --git a/ragfoundry/processing/local_steps/api/openai.py b/ragfoundry/processing/local_steps/api/openai.py index 8e6060d..76aaf89 100644 --- a/ragfoundry/processing/local_steps/api/openai.py +++ b/ragfoundry/processing/local_steps/api/openai.py @@ -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) diff --git a/ragfoundry/processing/local_steps/prompter.py b/ragfoundry/processing/local_steps/prompter.py index 0ea9d22..b9a2849 100644 --- a/ragfoundry/processing/local_steps/prompter.py +++ b/ragfoundry/processing/local_steps/prompter.py @@ -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 diff --git a/ragfoundry/processing/step.py b/ragfoundry/processing/step.py index 65c6fa0..7ddbaf0 100644 --- a/ragfoundry/processing/step.py +++ b/ragfoundry/processing/step.py @@ -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)