Coder Social home page Coder Social logo

fahmiaziz98 / synthetic-llm-qa-dataset-generator Goto Github PK

View Code? Open in Web Editor NEW

This project forked from nalinrajendran/synthetic-llm-qa-dataset-generator

0.0 0.0 0.0 8 KB

Create synthetic datasets for training and testing Language Learning Models (LLMs) in a Question-Answering (QA) context.

Python 100.00%

synthetic-llm-qa-dataset-generator's Introduction

OLLAMA Question-Answer Dataset Generator

This script is designed to generate a question-answer dataset from a given text, specifically from a PDF document. It uses the OLLAMA API, an OpenAI compatible API endpoint, to generate questions and answers based on the text content.

Key Features

  • Extract Text from PDF: The script can extract text from a PDF document using the PyPDF2 library.
  • Generate Questions and Answers: The script uses the OLLAMA API to generate questions and answers based on the extracted text.
  • Save Results: The generated question-answer pairs are saved in a JSON file.

How to Use

  1. Setup OLLAMA API: Before running the script, make sure to set up the OLLAMA API on your local machine. The API is invoked using the OpenAI format with the base URL set to 'http://localhost:11434/v1'. The API key is set to 'ollama', but it is not used in this script.

  2. Run the Script: Run the script in your Python environment. The script will read a PDF document, extract the text, generate questions and answers, and save the results in a JSON file.

  3. Specify the PDF Document: Specify the path to the PDF document in the extract_text_from_pdf function.

  4. Check the Results: The results are saved in a file named 'responses.json'. Check this file to see the generated question-answer pairs.

Important Note

This script uses the OLLAMA API, which is an OpenAI compatible API endpoint. The OLLAMA API is designed to work with large language models and provides a Docker Image for an OpenAI API compatible server for local LLMs. This makes it a powerful tool for generating question-answer pairs based on a given text.

Dependencies

  • OpenAI
  • PyPDF2
  • tqdm
  • json

Contribution

Feel free to contribute to this project by creating issues or sending pull requests. All contributions are welcome!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.