A Python package for generating educational content using Generative AI. Educhain makes it easy to apply Generative AI in various educational use cases to create engaging and personalized learning experiences
pip install educhain
Here are some examples on how to use educhain:
from educhain import qna_engine
questions = qna_engine.generate_mcq(
topic="Indian History",
level="Beginner",
num=5
)
questions
You can create your own prompt templates and customize it with various input fields
from educhain import qna_engine
custom_template = """
Generate {num} multiple-choice question (MCQ) based on the given topic and level.
Provide the question, four answer options, and the correct answer.
Topic: {topic}
Learning Objective: {learning_objective}
Difficulty Level: {difficulty_level}
"""
result = qna_engine.generate_mcq(
topic="Python Programming",
num=2,
learning_objective = "Usage of Python classes",
difficulty_level = "Hard",
prompt_template=custom_template,
)
result
Switch from default OpenAI models to other models using ChatOpenAI.
Example shows using Llama 3 model through Groq
from educhain import qna_engine
from langchain_openai import ChatOpenAI
llama3_groq = ChatOpenAI(
model = "llama3-70b-8192",
openai_api_base = "https://api.groq.com/openai/v1",
openai_api_key = "GROQ_API_KEY"
)
questions = qna_engine.generate_mcq(
topic="Chess",
level="Hard",
num=5,
llm = llama3_groq
)
questions
from educhain import to_json, to_pdf, to_csv
to_json(questions, "questions.json") # export questions to JSON
to_pdf(questions, "questions.pdf") # export questions to PDF
to_csv(questions, "questions.csv") # export questions to CSV
from educhain import content_engine
topic = "Medieval History"
level = "Beginner"
lesson_plan = content_engine.generate_lesson_plan(topic, level)
print(lesson_plan)
Contributions are welcome! Please open an issue or submit a pull request on the GitHub repository.
Will be releasing more features for MCQ Generation
- Bulk Generation
- Outputs in JSON format
- Custom Prompt Templates
- Custom Response Models using Pydantic
- Exports questions to JSON/PDF/CSV
- Support for other LLM models
- Generate questions from text/pdf file
- Finetuned Model for question generation