๐ A lightweight, LLM-powered tool to convert educational content into flashcards.
Flashcard.Demo.1.mp4
- Project Overview
- Features
- Tech Stack
- Setup and Installation
- How to Run
- Sample Execution
- Design Decisions & Prompt Engineering
- Project Structure
- Future Work
This tool streamlines the study process by automatically generating flashcards from educational content such as textbook chapters, lecture notes, or articles.
Built with Streamlit and powered by Zephyr-7B-ฮฒ (via Hugging Face), it offers an intuitive UI and delivers clean, structured Q&A flashcards that can be exported to Quizlet or CSV.
- โ
Multiple Content Inputs โ Paste text or upload
.txt
/.pdf
files. - โ LLM-Powered Generation โ Generate a custom number of flashcards using Zephyr-7B.
- โ Interactive UI โ Streamlit-based frontend for simplicity and clarity.
- โ Subject-Specific Context โ Optional subject selection improves relevance.
- โ
Quizlet Export โ Download in
.txt
format (tab-separated). - โ
CSV Export โ Download a
.csv
file of generated flashcards. - โ Robust JSON Parsing โ Handles minor LLM output errors for stable performance.
Layer | Tools / Libraries |
---|---|
Language | Python |
UI Framework | Streamlit |
Model | Zephyr-7B-ฮฒ via Hugging Face Inference API |
Text Processing | PyMuPDF (fitz) |
Data Handling | pandas |
JSON Parsing | demjson3 |
HTTP Requests | requests |
git clone https://github.com/Deepender25/FlashCard-Generator.git
cd FlashCard-Generator
For Unix/macOS:
python3 -m venv venv
source venv/bin/activate
For Windows:
python -m venv venv
venv\Scripts\activate
pip install -r requirements.txt
- Visit huggingface.co/settings/tokens and generate a User Access Token (with write permissions).
- Youโll be prompted to paste this token into the Streamlit sidebar during app usage.
streamlit run app.py
- Visit the local URL shown (usually
http://localhost:8501
) to access the app.
Photosynthesis is a process used by plants, algae, and certain bacteria to convert light energy into chemical energy...
[
{
"question": "What are the two stages of photosynthesis?",
"answer": "The two stages are the light-dependent reactions and the light-independent reactions (Calvin cycle)."
},
{
"question": "Where do the light-dependent reactions occur?",
"answer": "They occur in the thylakoid membranes of chloroplasts."
}
]
quizlet_import.txt
Where do the light-dependent reactions occur? They occur in the thylakoid membranes of chloroplasts.
flashcards.csv
question,answer
Where do the light-dependent reactions occur?,They occur in the thylakoid membranes of chloroplasts.
- Instruction-tuned for Q&A tasks
- Efficient and open-source
- Easy integration with Hugging Face Inference API
Prompt used in llm_handler_hf.py
:
prompt = f"""<|system|>
You are an expert flashcard creator. Your task is to generate exactly {num_cards} question-answer flashcards based on the provided text.
Your entire response MUST be a single, valid JSON list of objects. Each object must have a "question" key and an "answer" key.
Do not add any introduction, explanation, or any text outside of the main JSON list.
Your response must start with '[' and end with ']'.</s>
<|user|>
Generate flashcards for the following text on the subject of '{subject}':
---
{text}
---</s>
<|assistant|>
"""
fix_json_format()
strips out extra text or missing brackets.- Uses
demjson3
for lenient parsing. - Robust error handling for API failures, timeouts, and decoding issues.
.
โโโ app.py # Main Streamlit UI
โโโ llm_handler_hf.py # Hugging Face API & prompt logic
โโโ requirements.txt # Dependency list
โโโ .gitignore # Files to ignore in Git
โโโ .env.example # Example for API token handling
โโโ README.md # You're reading it!
- ๐ Flashcard Editor โ Let users edit flashcards before exporting.
- ๐ฆ Anki Export โ Add
.apkg
support viagenanki
. - ๐ง Topic Clustering โ Group questions by sub-topic or difficulty.
- ๐ Public Deployment โ Host on Streamlit Cloud or Hugging Face Spaces.
- ๐ Multi-language Support โ Generate flashcards in different languages.
This project is licensed under the MIT License.