This project implements a pipeline for contextual data augmentation using Large Language Models (LLMs). It focuses on enhancing free-response questions by converting them into multiple-choice format, leveraging the power of LLMs for intelligent and context-aware transformations. The pipeline utilizes Apache Beam for scalable and parallel data processing.
- LLM-Powered Augmentation: Uses Anthropic's Claude API to intelligently generate multiple-choice options for questions
- Contextual Understanding: Leverages LLM's ability to understand question context, including exam sections and labels
- Scalable Processing: Utilizes Apache Beam for efficient, parallel processing of large question sets
- Data Validation: Ensures input questions meet required schema before processing
- Firestore Integration: Stores augmented questions for easy retrieval and further use
- Input Processing: Reads free-response questions from a JSON input file
- Data Validation: Validates the structure and content of each question
- LLM Augmentation: Sends each question to the Claude API, which generates:
- Four contextually relevant multiple-choice options
- The correct answer
- An explanation (if requested)
- Data Transformation: Converts the free-response questions into multiple-choice format
- Data Storage: Writes the augmented questions to Firestore for persistence
- Go 1.15 or higher
- Google Cloud Project with Firestore enabled
- Anthropic API key for access to Claude
- Apache Beam SDK for Go
Set the following environment variables:
PROJECT_ID
: Your Google Cloud Project IDCOLLECTION
: Firestore collection name for storing augmented questionsCREDENTIALS_PATH
: Path to your Google Cloud credentials fileCLAUDE_API_KEY
: Your Anthropic API key
-
Clone the repository:
git clone https://github.com/yourusername/llm-data-augmentation-pipeline.git cd llm-data-augmentation-pipeline
-
Install dependencies:
go mod tidy
Run the augmentation pipeline with:
go run . --input=path/to/your/questions.json
main.go
: Entry point, sets up and runs the augmentation pipelinellm_client.go
: Implements the LLM client for question augmentationfirestore_client.go
: Handles writing augmented questions to Firestorequestion_parser.go
: Defines data structures and parsing logic for questionsfile_utils.go
: Utility functions for file operations
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License:
MIT License
Copyright (c) [2024] [Fermin Blanco]
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.