-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
= Enea_Gore
committed
Oct 30, 2024
1 parent
95e8492
commit 2483905
Showing
17 changed files
with
243 additions
and
203 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
modules/text/module_text_llm/module_text_llm/approach_controller.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
|
||
from typing import List | ||
from athena.text import Exercise, Submission, Feedback | ||
from module_text_llm.basic_approach import BasicApproachConfig | ||
from module_text_llm.chain_of_thought_approach import ChainOfThoughtConfig | ||
from module_text_llm.approach_config import ApproachConfig | ||
|
||
from module_text_llm.basic_approach.generate_suggestions import generate_suggestions as generate_suggestions_basic | ||
from module_text_llm.chain_of_thought_approach.generate_suggestions import generate_suggestions as generate_cot_suggestions | ||
|
||
async def generate_suggestions(exercise: Exercise, submission: Submission, config: ApproachConfig, debug: bool) -> List[Feedback]: | ||
if(isinstance(config, BasicApproachConfig)): | ||
return await generate_suggestions_basic(exercise, submission, config, debug) | ||
elif(isinstance(config, ChainOfThoughtConfig)): | ||
return await generate_cot_suggestions(exercise, submission, config, debug) | ||
|
18 changes: 0 additions & 18 deletions
18
modules/text/module_text_llm/module_text_llm/approaches/approach_controller.py
This file was deleted.
Oops, something went wrong.
26 changes: 0 additions & 26 deletions
26
modules/text/module_text_llm/module_text_llm/approaches/basic_approach/config.py
This file was deleted.
Oops, something went wrong.
31 changes: 0 additions & 31 deletions
31
...module_text_llm/module_text_llm/approaches/basic_approach/prompts/generate_suggestions.py
This file was deleted.
Oops, something went wrong.
36 changes: 0 additions & 36 deletions
36
modules/text/module_text_llm/module_text_llm/approaches/chain_of_thought_approach/config.py
This file was deleted.
Oops, something went wrong.
21 changes: 0 additions & 21 deletions
21
...m/module_text_llm/approaches/chain_of_thought_approach/prompts/refined_cot_suggestions.py
This file was deleted.
Oops, something went wrong.
11 changes: 11 additions & 0 deletions
11
modules/text/module_text_llm/module_text_llm/basic_approach/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
from module_text_llm.approach_config import ApproachConfig | ||
from pydantic import Field | ||
from typing import Literal | ||
|
||
|
||
from module_text_llm.basic_approach.prompt_generate_suggestions import GenerateSuggestionsPrompt | ||
|
||
class BasicApproachConfig(ApproachConfig): | ||
type: Literal['basic'] = 'basic' | ||
generate_suggestions_prompt: GenerateSuggestionsPrompt = Field(default=GenerateSuggestionsPrompt()) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
modules/text/module_text_llm/module_text_llm/basic_approach/prompt_generate_suggestions.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
from pydantic import Field, BaseModel | ||
from typing import List, Optional | ||
from pydantic import BaseModel, Field | ||
|
||
system_message = """\ | ||
You are an AI tutor for text assessment at a prestigious university. | ||
# Task | ||
Create graded feedback suggestions for a student\'s text submission that a human tutor would accept. \ | ||
Meaning, the feedback you provide should be applicable to the submission with little to no modification. | ||
# Style | ||
1. Constructive, 2. Specific, 3. Balanced, 4. Clear and Concise, 5. Actionable, 6. Educational, 7. Contextual | ||
# Problem statement | ||
{problem_statement} | ||
# Example solution | ||
{example_solution} | ||
# Grading instructions | ||
{grading_instructions} | ||
Max points: {max_points}, bonus points: {bonus_points}\ | ||
Respond in json. | ||
""" | ||
|
||
human_message = """\ | ||
Student\'s submission to grade (with sentence numbers <number>: <sentence>): | ||
Respond in json. | ||
\"\"\" | ||
{submission} | ||
\"\"\"\ | ||
""" | ||
|
||
# Input Prompt | ||
class GenerateSuggestionsPrompt(BaseModel): | ||
"""\ | ||
Features available: **{problem_statement}**, **{example_solution}**, **{grading_instructions}**, **{max_points}**, **{bonus_points}**, **{submission}** | ||
_Note: **{problem_statement}**, **{example_solution}**, or **{grading_instructions}** might be omitted if the input is too long._\ | ||
""" | ||
system_message: str = Field(default=system_message, | ||
description="Message for priming AI behavior and instructing it what to do.") | ||
human_message: str = Field(default=human_message, | ||
description="Message from a human. The input on which the AI is supposed to act.") | ||
# Output Object | ||
class FeedbackModel(BaseModel): | ||
title: str = Field(description="Very short title, i.e. feedback category or similar", example="Logic Error") | ||
description: str = Field(description="Feedback description") | ||
line_start: Optional[int] = Field(description="Referenced line number start, or empty if unreferenced") | ||
line_end: Optional[int] = Field(description="Referenced line number end, or empty if unreferenced") | ||
credits: float = Field(0.0, description="Number of points received/deducted") | ||
grading_instruction_id: Optional[int] = Field( | ||
description="ID of the grading instruction that was used to generate this feedback, or empty if no grading instruction was used" | ||
) | ||
|
||
|
||
class AssessmentModel(BaseModel): | ||
"""Collection of feedbacks making up an assessment""" | ||
|
||
feedbacks: List[FeedbackModel] = Field(description="Assessment feedbacks") | ||
|
15 changes: 15 additions & 0 deletions
15
modules/text/module_text_llm/module_text_llm/chain_of_thought_approach/__init__.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
from pydantic import BaseModel, Field | ||
from typing import Literal | ||
from llm_core.models import ModelConfigType, MiniModelConfig | ||
|
||
from module_text_llm.approach_config import ApproachConfig | ||
from module_text_llm.chain_of_thought_approach.prompt_generate_feedback import CoTGenerateSuggestionsPrompt | ||
from module_text_llm.chain_of_thought_approach.prompt_thinking import ThinkingPrompt | ||
|
||
class ChainOfThoughtConfig(ApproachConfig): | ||
# Defaults to the cheaper mini 4o model | ||
type: Literal['chain_of_thought'] = 'chain_of_thought' | ||
model: ModelConfigType = Field(default=MiniModelConfig) # type: ignore | ||
thikning_prompt: ThinkingPrompt = Field(default=ThinkingPrompt()) | ||
generate_suggestions_prompt: CoTGenerateSuggestionsPrompt = Field(default=CoTGenerateSuggestionsPrompt()) | ||
|
Oops, something went wrong.