robworks-software commited on
Commit
3e38595
Β·
verified Β·
1 Parent(s): bf6fb3b

Upload 3 files

Browse files
Files changed (3) hide show
  1. hf_space_README.md +85 -0
  2. hf_space_app.py +103 -0
  3. hf_space_requirements.txt +6 -0
hf_space_README.md ADDED
@@ -0,0 +1,85 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: CCISD TEKS Educational Assistant
3
+ emoji: πŸŽ“
4
+ colorFrom: blue
5
+ colorTo: green
6
+ sdk: gradio
7
+ sdk_version: 4.44.0
8
+ app_file: app.py
9
+ pinned: false
10
+ license: cc0-1.0
11
+ ---
12
+
13
+ # πŸŽ“ CCISD TEKS Educational Assistant
14
+
15
+ An AI-powered educational assistant specialized in **Texas Essential Knowledge and Skills (TEKS)** standards, trained on 4,224 enhanced examples covering all major subject areas.
16
+
17
+ ## πŸš€ What This Does
18
+
19
+ This chat interface allows teachers, students, and educational professionals to:
20
+
21
+ - **πŸ“š Understand TEKS Standards**: Get detailed explanations of any TEKS standard
22
+ - **πŸ‘¨β€πŸ« Teaching Strategies**: Receive pedagogically sound teaching approaches
23
+ - **🌎 Real-World Applications**: Discover how concepts apply to real life
24
+ - **βœ… Assessment Creation**: Generate quiz questions and evaluation criteria
25
+ - **🎯 Learning Objectives**: Identify prerequisites and learning progressions
26
+ - **πŸ’‘ Common Misconceptions**: Address typical student misunderstandings
27
+
28
+ ## 🧠 Model Details
29
+
30
+ - **Base Model**: [Mistral-7B-Instruct-v0.2](https://huggingface.co/mistralai/Mistral-7B-Instruct-v0.2)
31
+ - **Fine-Tuning**: LoRA (Low-Rank Adaptation) on 4,224 CCISD TEKS examples
32
+ - **Training Dataset**: [robworks-software/ccisd-teks-enhanced](https://huggingface.co/datasets/robworks-software/ccisd-teks-enhanced)
33
+ - **Training Method**: 4 epochs, T4 GPU, ~6 hours
34
+ - **Parameters**: 7B (7 billion)
35
+
36
+ ## πŸ“Š Dataset Coverage
37
+
38
+ The training dataset includes:
39
+
40
+ - **Mathematics**: Algebra, Geometry, Statistics, Calculus
41
+ - **Science**: Biology, Chemistry, Physics, Earth Science
42
+ - **English/Language Arts**: Reading, Writing, Language
43
+ - **Social Studies**: History, Geography, Economics, Government
44
+ - **Other Subjects**: Computer Science, Fine Arts, Career & Technical Education
45
+
46
+ Each example includes:
47
+ - TEKS standard code and description
48
+ - Detailed pedagogical explanations
49
+ - Real-world applications
50
+ - Teaching strategies
51
+ - Assessment approaches
52
+ - Common misconceptions
53
+ - Prerequisites and learning progressions
54
+
55
+ ## πŸ’» Usage
56
+
57
+ Simply type your question about Texas TEKS standards in the chat box. The model will provide detailed, accurate responses based on its training.
58
+
59
+ ### Example Questions:
60
+
61
+ - "What is TEKS standard MATH.A1.3.B?"
62
+ - "How should I teach the scientific method to 7th graders?"
63
+ - "What are real-world applications of linear equations?"
64
+ - "Create a quiz question about photosynthesis"
65
+ - "What are common misconceptions about fractions?"
66
+
67
+ ## πŸ“ License
68
+
69
+ This model and application are released under **CC0-1.0 (Public Domain Dedication)**.
70
+
71
+ The underlying TEKS standards are public domain educational content from the Texas Education Agency.
72
+
73
+ ## πŸ”— Links
74
+
75
+ - **Model**: [robworks-software/ccisd-teks-educator-mistral7b](https://huggingface.co/robworks-software/ccisd-teks-educator-mistral7b)
76
+ - **Training Dataset**: [robworks-software/ccisd-teks-enhanced](https://huggingface.co/datasets/robworks-software/ccisd-teks-enhanced)
77
+ - **Base Model**: [mistralai/Mistral-7B-Instruct-v0.2](https://huggingface.co/mistralai/Mistral-7B-Instruct-v0.2)
78
+
79
+ ## ⚠️ Disclaimer
80
+
81
+ This AI assistant is designed to support educational planning and understanding. While trained on authoritative TEKS standards, always verify critical information with official Texas Education Agency resources for formal curriculum planning.
82
+
83
+ ---
84
+
85
+ **Built with**: Mistral-7B + LoRA + Enhanced CCISD TEKS Dataset
hf_space_app.py ADDED
@@ -0,0 +1,103 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import AutoModelForCausalLM, AutoTokenizer
3
+ import torch
4
+
5
+ print("πŸ”„ Loading CCISD TEKS Educational Assistant...")
6
+ print(" This may take 1-2 minutes on first launch...")
7
+
8
+ # Load your trained model
9
+ MODEL_NAME = "robworks-software/ccisd-teks-educator-mistral7b"
10
+
11
+ tokenizer = AutoTokenizer.from_pretrained(MODEL_NAME)
12
+ model = AutoModelForCausalLM.from_pretrained(
13
+ MODEL_NAME,
14
+ torch_dtype=torch.float16,
15
+ device_map="auto",
16
+ low_cpu_mem_usage=True
17
+ )
18
+
19
+ print("βœ… Model loaded successfully!")
20
+
21
+ def chat(message, history):
22
+ """
23
+ Generate response using Mistral chat format.
24
+
25
+ Args:
26
+ message: Current user message
27
+ history: List of [user_msg, bot_msg] pairs
28
+
29
+ Returns:
30
+ Generated response string
31
+ """
32
+
33
+ # Build conversation history in Mistral format
34
+ prompt = ""
35
+ for user_msg, bot_msg in history:
36
+ prompt += f"[INST] {user_msg} [/INST] {bot_msg}</s> "
37
+
38
+ # Add current message with system instruction
39
+ system_message = "You are an expert educational AI assistant specializing in Texas Essential Knowledge and Skills (TEKS) standards. Provide accurate, detailed, and pedagogically sound information to help teachers and students."
40
+
41
+ prompt += f"[INST] {system_message}\n\n{message} [/INST]"
42
+
43
+ # Tokenize
44
+ inputs = tokenizer(prompt, return_tensors="pt").to(model.device)
45
+
46
+ # Generate response
47
+ with torch.no_grad():
48
+ outputs = model.generate(
49
+ **inputs,
50
+ max_new_tokens=512,
51
+ temperature=0.7,
52
+ top_p=0.9,
53
+ do_sample=True,
54
+ pad_token_id=tokenizer.eos_token_id,
55
+ eos_token_id=tokenizer.eos_token_id,
56
+ )
57
+
58
+ # Decode response
59
+ response = tokenizer.decode(outputs[0], skip_special_tokens=True)
60
+
61
+ # Extract answer after [/INST]
62
+ if "[/INST]" in response:
63
+ response = response.split("[/INST]")[-1].strip()
64
+
65
+ return response
66
+
67
+
68
+ # Create Gradio ChatInterface
69
+ demo = gr.ChatInterface(
70
+ fn=chat,
71
+ title="πŸŽ“ CCISD TEKS Educational Assistant",
72
+ description="""
73
+ **Powered by Mistral-7B fine-tuned on 4,224 enhanced CCISD TEKS examples**
74
+
75
+ Ask questions about:
76
+ - πŸ“š TEKS standard definitions and explanations
77
+ - πŸ‘¨β€πŸ« Teaching strategies and lesson planning
78
+ - 🌎 Real-world applications
79
+ - βœ… Assessment and quiz generation
80
+ - 🎯 Learning objectives and prerequisites
81
+ - πŸ’‘ Common student misconceptions
82
+
83
+ *Trained on Texas TEKS standards with real-world educational data.*
84
+ """,
85
+ examples=[
86
+ "What is TEKS standard MATH.A1.3.B?",
87
+ "How should I teach the scientific method to 7th grade students?",
88
+ "What are real-world applications of linear equations?",
89
+ "Create a quiz question to assess understanding of photosynthesis",
90
+ "What are common misconceptions students have about fractions?",
91
+ "Explain ELAR.9.1.A and suggest a lesson activity",
92
+ ],
93
+ theme="soft",
94
+ chatbot=gr.Chatbot(height=500),
95
+ textbox=gr.Textbox(placeholder="Ask me about Texas TEKS standards...", container=False, scale=7),
96
+ retry_btn="πŸ”„ Retry",
97
+ undo_btn="↩️ Undo",
98
+ clear_btn="πŸ—‘οΈ Clear",
99
+ )
100
+
101
+ # Launch the app
102
+ if __name__ == "__main__":
103
+ demo.launch()
hf_space_requirements.txt ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ gradio>=4.0.0
2
+ transformers>=4.35.0
3
+ torch>=2.0.0
4
+ accelerate>=0.24.0
5
+ sentencepiece>=0.1.99
6
+ protobuf>=3.20.0