mjschock commited on
Commit
7461cd0
·
unverified ·
1 Parent(s): 2da6a11

Enhance project structure by adding new files and updating dependencies. Introduce model_factory.py for streamlined model creation using environment variables. Update .gitignore to exclude additional cache and model files. Modify main_v2.py to utilize ModelFactory for model instantiation and adjust API key loading. Expand requirements.txt with new dependencies for improved functionality. Add new notebooks for fine-tuning and model training, enhancing project documentation and usability.

Browse files
.gitignore CHANGED
@@ -1,4 +1,8 @@
1
  .env
 
 
2
  __pycache__
3
  .pytest_cache
 
4
  .venv
 
 
1
  .env
2
+ lora_model
3
+ outputs
4
  __pycache__
5
  .pytest_cache
6
+ unsloth_compiled_cache
7
  .venv
8
+ wandb
main_v2.py CHANGED
@@ -13,6 +13,7 @@ from smolagents import CodeAgent, LiteLLMModel
13
  from smolagents.monitoring import LogLevel
14
 
15
  from tools.smart_search.tool import SmartSearchTool
 
16
 
17
  _disable_debugging()
18
 
@@ -25,17 +26,14 @@ logging.basicConfig(
25
  )
26
  logger = logging.getLogger(__name__)
27
 
28
- load_dotenv(find_dotenv())
29
 
30
- API_BASE = os.getenv("API_BASE")
31
- API_KEY = os.getenv("API_KEY")
32
- MODEL_ID = os.getenv("MODEL_ID")
33
 
34
- model = LiteLLMModel(
35
- api_base=API_BASE,
36
- api_key=API_KEY,
37
- model_id=MODEL_ID,
38
- )
39
 
40
  # data_agent = create_data_agent(model)
41
  # media_agent = create_media_agent(model)
@@ -140,7 +138,7 @@ if __name__ == "__main__":
140
  response.raise_for_status()
141
  questions_data = response.json()
142
 
143
- for question_data in questions_data[:2]:
144
  file_name = question_data["file_name"]
145
  level = question_data["Level"]
146
  question = question_data["question"]
 
13
  from smolagents.monitoring import LogLevel
14
 
15
  from tools.smart_search.tool import SmartSearchTool
16
+ from model_factory import ModelFactory
17
 
18
  _disable_debugging()
19
 
 
26
  )
27
  logger = logging.getLogger(__name__)
28
 
29
+ # load_dotenv(find_dotenv())
30
 
31
+ # API_BASE = os.getenv("API_BASE")
32
+ # API_KEY = os.getenv("API_KEY")
33
+ # MODEL_ID = os.getenv("MODEL_ID")
34
 
35
+ # Create model using the factory
36
+ model = ModelFactory.create_model()
 
 
 
37
 
38
  # data_agent = create_data_agent(model)
39
  # media_agent = create_media_agent(model)
 
138
  response.raise_for_status()
139
  questions_data = response.json()
140
 
141
+ for question_data in questions_data[:1]:
142
  file_name = question_data["file_name"]
143
  level = question_data["Level"]
144
  question = question_data["question"]
model_factory.py ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ from dotenv import find_dotenv, load_dotenv
3
+ from smolagents import LiteLLMModel, TransformersModel
4
+
5
+ class ModelFactory:
6
+ @staticmethod
7
+ def create_model():
8
+ """
9
+ Creates and returns a LiteLLMModel instance configured with environment variables.
10
+
11
+ Returns:
12
+ LiteLLMModel: A configured instance of LiteLLMModel
13
+ """
14
+ # Load environment variables
15
+ load_dotenv(find_dotenv())
16
+
17
+ # Get configuration from environment variables
18
+ api_base = os.getenv("API_BASE")
19
+ api_key = os.getenv("API_KEY")
20
+ model_id = os.getenv("MODEL_ID")
21
+
22
+ # Create and return the model
23
+ # return LiteLLMModel(
24
+ # api_base=api_base,
25
+ # api_key=api_key,
26
+ # model_id=model_id,
27
+ # )
28
+
29
+ return TransformersModel(
30
+ # max_new_tokens=5000,
31
+ max_new_tokens=256,
32
+ model_id="HuggingFaceTB/SmolLM2-135M-Instruct",
33
+ # model_id="HuggingFaceTB/SmolLM2-360M-Instruct",
34
+ # model_id="HuggingFaceTB/SmolLM2-1.7B-Instruct",
35
+ # model_id="HuggingFaceTB/SmolVLM2-256M-Video-Instruct",
36
+ # model_id="Qwen/Qwen2.5-Coder-32B-Instruct",
37
+ )
notebooks/SmolVLM2_Video_FT.ipynb ADDED
The diff for this file is too large to render. See raw diff
 
notebooks/bonus-unit1.ipynb ADDED
The diff for this file is too large to render. See raw diff
 
notebooks/unsloth_SmolLM2-135M-Instruct-bnb-4bit_xingyaoww_code-act.ipynb ADDED
The diff for this file is too large to render. See raw diff
 
requirements.txt CHANGED
@@ -1,7 +1,12 @@
 
1
  beautifulsoup4>=4.13.4
 
2
  duckduckgo-search>=8.0.1
3
  gradio[oauth]>=5.26.0
 
 
4
  isort>=6.0.1
 
5
  kagglehub>=0.3.12
6
  langchain>=0.1.0
7
  langchain-community>=0.0.10
@@ -12,15 +17,20 @@ llama-index-embeddings-huggingface>=0.5.3
12
  llama-index-readers-wikipedia>=0.3.0
13
  markdown>=3.8
14
  mlcroissant>=1.0.17
 
15
  numpy>=2.2.5
16
  pandas>=2.0.0
 
17
  pytest>=8.3.5
18
  pytest-cov>=6.1.1
19
  python-dotenv>=1.0.0
20
  requests>=2.32.3
21
  sentence-transformers>=4.1.0
22
  smolagents[litellm,telemetry]>=1.14.0
 
 
23
  typing-extensions>=4.5.0
24
- hf-xet>=1.0.5
 
25
  wikipedia>=1.4.0
26
  wikipedia-api>=0.8.1
 
1
+ accelerate>=1.6.0
2
  beautifulsoup4>=4.13.4
3
+ bitsandbytes>=0.45.5
4
  duckduckgo-search>=8.0.1
5
  gradio[oauth]>=5.26.0
6
+ hf-xet>=1.0.5
7
+ ipywidgets>=8.1.6
8
  isort>=6.0.1
9
+ jupyter>=1.1.1
10
  kagglehub>=0.3.12
11
  langchain>=0.1.0
12
  langchain-community>=0.0.10
 
17
  llama-index-readers-wikipedia>=0.3.0
18
  markdown>=3.8
19
  mlcroissant>=1.0.17
20
+ num2words>=0.5.14
21
  numpy>=2.2.5
22
  pandas>=2.0.0
23
+ peft>=0.15.2
24
  pytest>=8.3.5
25
  pytest-cov>=6.1.1
26
  python-dotenv>=1.0.0
27
  requests>=2.32.3
28
  sentence-transformers>=4.1.0
29
  smolagents[litellm,telemetry]>=1.14.0
30
+ tensorboardX>=2.6.2.2
31
+ trl>=0.17.0
32
  typing-extensions>=4.5.0
33
+ unsloth>=2025.4.3
34
+ wandb>=0.19.10
35
  wikipedia>=1.4.0
36
  wikipedia-api>=0.8.1