Aditya2162 commited on
Commit
3d2dbcf
·
verified ·
1 Parent(s): 06711d1

Upload folder using huggingface_hub

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .dockerignore +21 -0
  2. .gitattributes +16 -0
  3. .gitignore +18 -0
  4. Dockerfile.openenv-api +82 -0
  5. Dockerfile.visualizer +41 -0
  6. README.md +199 -0
  7. __init__.py +1 -0
  8. agents/README.md +20 -0
  9. agents/__init__.py +15 -0
  10. agents/district_controller.py +187 -0
  11. agents/district_coordinator.py +11 -0
  12. agents/heuristic_controller.py +91 -0
  13. agents/local_policy.py +110 -0
  14. agents/message_protocol.py +116 -0
  15. artifacts/README.md +3 -0
  16. artifacts/district_llm_adapter_v2/README.md +63 -0
  17. artifacts/district_llm_adapter_v2/adapter_config.json +50 -0
  18. artifacts/district_llm_adapter_v2/adapter_model.safetensors +3 -0
  19. artifacts/district_llm_adapter_v2/checkpoint-100/README.md +210 -0
  20. artifacts/district_llm_adapter_v2/checkpoint-100/adapter_config.json +50 -0
  21. artifacts/district_llm_adapter_v2/checkpoint-100/adapter_model.safetensors +3 -0
  22. artifacts/district_llm_adapter_v2/checkpoint-100/optimizer.pt +3 -0
  23. artifacts/district_llm_adapter_v2/checkpoint-100/rng_state.pth +3 -0
  24. artifacts/district_llm_adapter_v2/checkpoint-100/scheduler.pt +3 -0
  25. artifacts/district_llm_adapter_v2/checkpoint-100/tokenizer.json +3 -0
  26. artifacts/district_llm_adapter_v2/checkpoint-100/tokenizer_config.json +18 -0
  27. artifacts/district_llm_adapter_v2/checkpoint-100/trainer_state.json +174 -0
  28. artifacts/district_llm_adapter_v2/checkpoint-100/training_args.bin +3 -0
  29. artifacts/district_llm_adapter_v2/checkpoint-150/README.md +210 -0
  30. artifacts/district_llm_adapter_v2/checkpoint-150/adapter_config.json +50 -0
  31. artifacts/district_llm_adapter_v2/checkpoint-150/adapter_model.safetensors +3 -0
  32. artifacts/district_llm_adapter_v2/checkpoint-150/optimizer.pt +3 -0
  33. artifacts/district_llm_adapter_v2/checkpoint-150/rng_state.pth +3 -0
  34. artifacts/district_llm_adapter_v2/checkpoint-150/scheduler.pt +3 -0
  35. artifacts/district_llm_adapter_v2/checkpoint-150/tokenizer.json +3 -0
  36. artifacts/district_llm_adapter_v2/checkpoint-150/tokenizer_config.json +18 -0
  37. artifacts/district_llm_adapter_v2/checkpoint-150/trainer_state.json +244 -0
  38. artifacts/district_llm_adapter_v2/checkpoint-150/training_args.bin +3 -0
  39. artifacts/district_llm_adapter_v2/checkpoint-200/README.md +210 -0
  40. artifacts/district_llm_adapter_v2/checkpoint-200/adapter_config.json +50 -0
  41. artifacts/district_llm_adapter_v2/checkpoint-200/adapter_model.safetensors +3 -0
  42. artifacts/district_llm_adapter_v2/checkpoint-200/optimizer.pt +3 -0
  43. artifacts/district_llm_adapter_v2/checkpoint-200/rng_state.pth +3 -0
  44. artifacts/district_llm_adapter_v2/checkpoint-200/scheduler.pt +3 -0
  45. artifacts/district_llm_adapter_v2/checkpoint-200/tokenizer.json +3 -0
  46. artifacts/district_llm_adapter_v2/checkpoint-200/tokenizer_config.json +18 -0
  47. artifacts/district_llm_adapter_v2/checkpoint-200/trainer_state.json +314 -0
  48. artifacts/district_llm_adapter_v2/checkpoint-200/training_args.bin +3 -0
  49. artifacts/district_llm_adapter_v2/checkpoint-250/README.md +210 -0
  50. artifacts/district_llm_adapter_v2/checkpoint-250/adapter_config.json +50 -0
.dockerignore ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .git
2
+ .venv
3
+ __pycache__/
4
+ .pytest_cache/
5
+ .mypy_cache/
6
+ .ruff_cache/
7
+
8
+ data/generated/
9
+ data/district_llm_dataset_v1/
10
+ data/district_llm_dataset_v2/
11
+ data/district_llm_dataset_v3/
12
+
13
+ artifacts/district_llm_adapter_v2/
14
+ artifacts/dqn_shared/checkpoints/
15
+ artifacts/dqn_shared/tensorboard/
16
+ artifacts/llm_runtime_diagnosis/
17
+ artifacts/quick_rl_llm_eval/
18
+ artifacts/rl_guidance_eval/
19
+ artifacts/rl_llm_wrapper_sweep/
20
+
21
+ notebooks/
.gitattributes CHANGED
@@ -33,3 +33,19 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ artifacts/district_llm_adapter_v2/checkpoint-100/tokenizer.json filter=lfs diff=lfs merge=lfs -text
37
+ artifacts/district_llm_adapter_v2/checkpoint-150/tokenizer.json filter=lfs diff=lfs merge=lfs -text
38
+ artifacts/district_llm_adapter_v2/checkpoint-200/tokenizer.json filter=lfs diff=lfs merge=lfs -text
39
+ artifacts/district_llm_adapter_v2/checkpoint-250/tokenizer.json filter=lfs diff=lfs merge=lfs -text
40
+ artifacts/district_llm_adapter_v2/checkpoint-300/tokenizer.json filter=lfs diff=lfs merge=lfs -text
41
+ artifacts/district_llm_adapter_v2/checkpoint-50/tokenizer.json filter=lfs diff=lfs merge=lfs -text
42
+ artifacts/district_llm_adapter_v2/tokenizer.json filter=lfs diff=lfs merge=lfs -text
43
+ artifacts/district_llm_adapter_v3/main_run/adapter/tokenizer.json filter=lfs diff=lfs merge=lfs -text
44
+ artifacts/district_llm_adapter_v3/main_run/checkpoints/checkpoint-100/tokenizer.json filter=lfs diff=lfs merge=lfs -text
45
+ artifacts/district_llm_adapter_v3/main_run/checkpoints/checkpoint-150/tokenizer.json filter=lfs diff=lfs merge=lfs -text
46
+ artifacts/district_llm_adapter_v3/main_run/checkpoints/checkpoint-200/tokenizer.json filter=lfs diff=lfs merge=lfs -text
47
+ artifacts/district_llm_adapter_v3/main_run/checkpoints/checkpoint-50/tokenizer.json filter=lfs diff=lfs merge=lfs -text
48
+ third_party/CityFlow/examples/replay.txt filter=lfs diff=lfs merge=lfs -text
49
+ third_party/CityFlow/extern/pybind11/.git.bak/objects/pack/pack-0b2353194187af7e228cfabd32025bb4d3af8551.idx filter=lfs diff=lfs merge=lfs -text
50
+ third_party/CityFlow/extern/pybind11/.git.bak/objects/pack/pack-0b2353194187af7e228cfabd32025bb4d3af8551.pack filter=lfs diff=lfs merge=lfs -text
51
+ third_party/CityFlow/extern/pybind11/.git.bak/objects/pack/pack-0b2353194187af7e228cfabd32025bb4d3af8551.rev filter=lfs diff=lfs merge=lfs -text
.gitignore ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ __pycache__
2
+ *.pyc
3
+ data/generated/*
4
+ .DS_Store
5
+ data/
6
+ build/
7
+ build-docker/
8
+ local/
9
+ .vs/
10
+ .vscode/
11
+ .idea/
12
+ .DS_Store
13
+ __pycache__
14
+ CMakeSettings.json
15
+ cmake-build-*
16
+ CityFlow.egg-info
17
+ frontend/replay/*
18
+ notebooks/unsloth_compiled_cache
Dockerfile.openenv-api ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # OpenEnv API container
2
+ #
3
+ # Two-stage build:
4
+ # 1. builder - compiles the vendored CityFlow Python extension
5
+ # 2. runtime - installs the API dependencies and copies the repo-local data
6
+ #
7
+ # Runtime env vars:
8
+ # DATA_DIR generated CityFlow dataset root
9
+ # default: /app/data/generated
10
+ # SPLITS_DIR train/val/test split files
11
+ # default: /app/data/splits
12
+ # CHECKPOINT_PATH optional DQN checkpoint
13
+ # default: /app/artifacts/dqn_shared/best_validation.pt
14
+ # ---------------------------------------------------------------------------
15
+
16
+ # ── Stage 1: Build CityFlow ─────────────────────────────────────────────────
17
+ FROM python:3.12-slim AS builder
18
+
19
+ # Build tools needed by CityFlow's CMake build
20
+ RUN apt-get update && apt-get install -y --no-install-recommends \
21
+ build-essential \
22
+ cmake \
23
+ libboost-all-dev \
24
+ && rm -rf /var/lib/apt/lists/*
25
+
26
+ WORKDIR /build
27
+
28
+ # Copy only the CityFlow source (pybind11 is bundled as an extern submodule)
29
+ COPY third_party/CityFlow ./CityFlow
30
+
31
+ # Build and install cityflow into the builder's site-packages
32
+ RUN rm -rf ./CityFlow/build
33
+ RUN pip install --no-cache-dir ./CityFlow
34
+
35
+ # Locate the compiled .so so we can copy it to the runtime stage
36
+ RUN python -c "import cityflow, os; print(os.path.dirname(cityflow.__file__))"
37
+
38
+
39
+ # ── Stage 2: Runtime ────────────────────────────────────────────────────────
40
+ FROM python:3.12-slim AS runtime
41
+
42
+ WORKDIR /app
43
+
44
+ # Copy the compiled cityflow extension from the builder
45
+ COPY --from=builder /usr/local/lib/python3.12/site-packages/cityflow* \
46
+ /usr/local/lib/python3.12/site-packages/
47
+
48
+ # Install Python dependencies (no build tools needed here)
49
+ COPY openenv_app/requirements.txt ./requirements.txt
50
+ RUN pip install --no-cache-dir -r requirements.txt
51
+
52
+ # Copy application source (only what the OpenEnv API needs at runtime)
53
+ COPY agents/ ./agents/
54
+ COPY district_llm/ ./district_llm/
55
+ COPY env/ ./env/
56
+ COPY openenv_app/ ./openenv_app/
57
+ COPY server/__init__.py ./server/__init__.py
58
+ COPY server/path_validators.py ./server/path_validators.py
59
+ COPY server/policy_runner.py ./server/policy_runner.py
60
+ COPY server/roadnet_matcher.py ./server/roadnet_matcher.py
61
+ COPY training/ ./training/
62
+ COPY data/splits/ ./data/splits/
63
+ COPY data/generated/city_0002/ ./data/generated/city_0002/
64
+ COPY artifacts/dqn_shared/best_validation.pt ./artifacts/dqn_shared/best_validation.pt
65
+ COPY artifacts/district_llm_adapter_v3/main_run/adapter/ ./artifacts/district_llm_adapter_v3/main_run/adapter/
66
+
67
+ # Keep runtime paths present, but expect the actual generated dataset to be
68
+ # mounted or synced separately instead of baked into the image.
69
+ RUN mkdir -p /app/data/generated /app/data/splits
70
+
71
+ # Default paths (overridable at runtime via env vars).
72
+ # DATA_DIR must point at a mounted/generated dataset root that contains city_*/
73
+ # directories and scenario files; only data/splits is bundled here.
74
+ ENV DATA_DIR=/app/data/generated
75
+ ENV SPLITS_DIR=/app/data/splits
76
+ ENV CHECKPOINT_PATH=/app/artifacts/dqn_shared/best_validation.pt
77
+ ENV DISTRICT_LLM_ADAPTER_PATH=/app/artifacts/district_llm_adapter_v3/main_run/adapter
78
+
79
+ # OpenEnv and HF Spaces commonly use port 7860.
80
+ EXPOSE 7860
81
+
82
+ CMD ["sh", "-c", "uvicorn openenv_app.app:app --host 0.0.0.0 --port ${PORT:-7860}"]
Dockerfile.visualizer ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # ── HF Space 2: Visualizer Dashboard ──────────────────────────────────────
2
+ #
3
+ # Lightweight image — no CityFlow C++ build, no torch.
4
+ # All simulation runs are delegated to Space 1 (OpenEnv API) via HTTP.
5
+ #
6
+ # HF Spaces expects the app to listen on port 7860.
7
+ #
8
+ # Required env vars (set in the Space settings or README front matter):
9
+ # OPENENV_API_URL URL of the OpenEnv API Space
10
+ # e.g. https://your-org-openenv-api.hf.space
11
+ #
12
+ # Optional:
13
+ # DATA_DIR city config root for roadnet matching (default: /app/data/bundled)
14
+ # REPLAY_ROOT where replays are cached on disk (default: /app/results/replays)
15
+ # ---------------------------------------------------------------------------
16
+
17
+ FROM python:3.12-slim
18
+
19
+ WORKDIR /app
20
+
21
+ # Install dependencies (no cmake / build-essential needed)
22
+ COPY server/requirements.txt ./requirements.txt
23
+ RUN pip install --no-cache-dir -r requirements.txt
24
+
25
+ # Application source
26
+ COPY server/ ./server/
27
+ COPY third_party/CityFlow/frontend/ ./third_party/CityFlow/frontend/
28
+
29
+ # Bundled city data (for roadnet matching / city/scenario dropdowns)
30
+ COPY data/bundled/ ./data/bundled/
31
+ COPY data/splits/ ./data/splits/
32
+
33
+ # Writable directory for cached replays
34
+ RUN mkdir -p /app/results/replays
35
+
36
+ ENV DATA_DIR=/app/data/bundled
37
+ ENV REPLAY_ROOT=/app/results/replays
38
+
39
+ EXPOSE 7860
40
+
41
+ CMD ["uvicorn", "server.visualizer_app:app", "--host", "0.0.0.0", "--port", "7860"]
README.md ADDED
@@ -0,0 +1,199 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: Agentic Traffic
3
+ emoji: 🏢
4
+ colorFrom: green
5
+ colorTo: purple
6
+ sdk: docker
7
+ pinned: false
8
+ short_description: Agentic AI to control traffic lights
9
+ app_port: 7860
10
+ ---
11
+
12
+ # traffic-llm
13
+
14
+ CityFlow-based traffic-control project with intersection-level multi-agent DQN training and district-aware policy variants.
15
+
16
+ ## OpenEnv UI
17
+
18
+ For the deployed OpenEnv web interface:
19
+
20
+ - Click `Reset` before using `Step`.
21
+ - Leave `Use Llm` unchecked for the fast, stable DQN-only path.
22
+ - Use `District Actions` = `{}` for a valid no-op step payload.
23
+ - Only enable `Use Llm` when you explicitly want district-level LLM guidance on top of the DQN executor.
24
+
25
+ ## Training
26
+
27
+ The default local-policy trainer now uses parameter-shared dueling Double DQN with prioritized replay and n-step returns:
28
+
29
+ ```bash
30
+ python3 -m training.train_local_policy train
31
+ ```
32
+
33
+ That trains against `data/generated`, uses `data/splits`, writes checkpoints to `artifacts/dqn_shared`, enables TensorBoard logging, uses parallel CPU rollout workers by default, shows `tqdm` progress bars, and now validates plus checkpoints every 40 updates by default.
34
+
35
+ For a broader but still manageable validation pass:
36
+
37
+ ```bash
38
+ python3 -m training.train_local_policy train --max-val-cities 3 --val-scenarios-per-city 7
39
+ ```
40
+
41
+ That evaluates 3 validation cities across all 7 scenario types. This gives 21 learned-policy validation episodes per eval, or 63 total episodes if random and fixed baselines are also enabled.
42
+
43
+ Phase-3-style full training with the same 40-update eval/checkpoint cadence:
44
+
45
+ ```bash
46
+ python3 -m training.train_local_policy train \
47
+ --max-train-cities 70 \
48
+ --max-val-cities 3 \
49
+ --val-scenarios-per-city 7 \
50
+ --policy-arch single_head_with_district_feature \
51
+ --reward-variant wait_queue_throughput
52
+ ```
53
+
54
+ Useful ablations:
55
+
56
+ ```bash
57
+ python3 -m training.train_local_policy train --policy-arch multi_head --reward-variant current
58
+ python3 -m training.train_local_policy train --policy-arch single_head --reward-variant current
59
+ python3 -m training.train_local_policy train --policy-arch single_head_with_district_feature --reward-variant wait_queue_throughput
60
+ ```
61
+
62
+ For a fast phase-1 overfit run on one fixed world:
63
+
64
+ ```bash
65
+ python3 -m training.train_local_policy train \
66
+ --total-updates 25 \
67
+ --train-city-id city_0072 \
68
+ --train-scenario-name normal \
69
+ --overfit-val-on-train-scenario \
70
+ --fast-overfit \
71
+ --policy-arch single_head_with_district_feature \
72
+ --reward-variant wait_queue_throughput
73
+ ```
74
+
75
+ To create or refresh dataset splits:
76
+
77
+ ```bash
78
+ python3 -m training.train_local_policy make-splits
79
+ ```
80
+
81
+ To evaluate the best checkpoint:
82
+
83
+ ```bash
84
+ python3 -m training.train_local_policy evaluate \
85
+ --checkpoint artifacts/dqn_shared/best_validation.pt \
86
+ --split val
87
+ ```
88
+
89
+ To evaluate a heuristic baseline directly:
90
+
91
+ ```bash
92
+ python3 -m training.train_local_policy evaluate --baseline queue_greedy --split val
93
+ ```
94
+
95
+ ## TensorBoard
96
+
97
+ TensorBoard logs are written to `artifacts/dqn_shared/tensorboard` by default.
98
+
99
+ ```bash
100
+ tensorboard --logdir artifacts/dqn_shared/tensorboard
101
+ ```
102
+
103
+ ## District LLM
104
+
105
+ The district LLM stack lives under `district_llm/`. It treats the learned DQN local controller as the low-level executor, derives district-scale SFT labels automatically from DQN rollout windows, and defaults district-model fine-tuning to DQN-derived rows only.
106
+
107
+ Generate district-LLM data from a learned checkpoint:
108
+
109
+ ```bash
110
+ python3 -m district_llm.generate_dataset \
111
+ --controller rl_checkpoint \
112
+ --checkpoint artifacts/dqn_shared/best_validation.pt \
113
+ --episodes 100 \
114
+ --decision-interval 10 \
115
+ --use-checkpoint-env-config \
116
+ --output data/district_llm_train.jsonl
117
+ ```
118
+
119
+ Generate from fixed or heuristic baselines:
120
+
121
+ ```bash
122
+ python3 -m district_llm.generate_dataset --controller fixed --episodes 50 --decision-interval 10 --output data/district_llm_fixed.jsonl
123
+ python3 -m district_llm.generate_dataset --controller queue_greedy --episodes 50 --decision-interval 10 --output data/district_llm_heuristic.jsonl
124
+ python3 -m district_llm.generate_dataset --teacher-spec fixed --teacher-spec random --episodes 50 --decision-interval 10 --output data/district_llm_multi_teacher.jsonl
125
+ ```
126
+
127
+ Train a first-pass district model with Unsloth/QLoRA:
128
+
129
+ ```bash
130
+ python3 -m training.train_district_llm \
131
+ --dataset data/district_llm_train.jsonl \
132
+ --output-dir artifacts/district_llm_qwen \
133
+ --model-name Qwen/Qwen2.5-7B-Instruct \
134
+ --load-in-4bit \
135
+ --lora-rank 16 \
136
+ --max-seq-length 1024 \
137
+ --max-steps 1000
138
+ ```
139
+
140
+ Run single-sample inference:
141
+
142
+ ```bash
143
+ python3 -m district_llm.inference \
144
+ --model artifacts/district_llm_qwen \
145
+ --city-id city_0006 \
146
+ --scenario-name accident \
147
+ --district-id d_00
148
+ ```
149
+
150
+ Run the OpenEnv-compatible district wrapper on top of the current DQN stack:
151
+
152
+ ```bash
153
+ uvicorn openenv_app.app:app --reload
154
+ ```
155
+
156
+ ## Algorithm
157
+
158
+ - Training algorithm: parameter-shared dueling Double DQN.
159
+ - Replay: prioritized replay over per-intersection transitions gathered from full CityFlow worlds.
160
+ - Return target: n-step bootstrap target with target-network updates.
161
+ - Execution: all controllable intersections act simultaneously every RL decision interval.
162
+ - Action space: `0 = hold current phase`, `1 = switch to next green phase`.
163
+ - Safety: `min_green_time` is enforced in the environment and exposed through action masking.
164
+
165
+ Policy architecture modes:
166
+
167
+ - `multi_head`: shared trunk with district-type-specific Q heads.
168
+ - `single_head`: one shared Q head for all intersections, with district type removed from the observation.
169
+ - `single_head_with_district_feature`: one shared Q head for all intersections, with district type left in the observation as an explicit feature.
170
+
171
+ Reward variants:
172
+
173
+ - `current`: backward-compatible waiting and queue penalty.
174
+ - `normalized_wait_queue`: normalized queue and waiting reduction reward.
175
+ - `wait_queue_throughput`: normalized queue/wait reduction plus throughput bonus and imbalance penalty.
176
+
177
+ ## Smoke Test
178
+
179
+ To sanity-check one generated scenario with the real CityFlow environment:
180
+
181
+ ```bash
182
+ python3 scripts/smoke_test_env.py --city-id city_0001 --scenario-name normal --policy random
183
+ ```
184
+
185
+ ## Project layout
186
+
187
+ - `agents/`: heuristic local policies and simple baselines.
188
+ - `env/`: CityFlow environment, topology parsing, observation building, and reward logic.
189
+ - `training/`: dataset utilities, replay-based DQN training, evaluation helpers, TensorBoard logging, and CLIs.
190
+ - `data/`: generated synthetic cities, split files, and dataset generation utilities.
191
+ - `scripts/`: utility scripts, including the CityFlow smoke test.
192
+ - `third_party/`: vendored dependencies, including CityFlow source.
193
+
194
+ ## Notes
195
+
196
+ - The generated dataset is assumed to already exist under `data/generated`.
197
+ - District membership comes from `district_map.json`.
198
+ - District types come from `metadata.json`.
199
+ - Runtime training and evaluation require the `cityflow` Python module to be installed in the active environment.
__init__.py ADDED
@@ -0,0 +1 @@
 
 
1
+ """OpenEnv package root for the lean agentic traffic environment."""
agents/README.md ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # agents
2
+
3
+ Local traffic-control policies and compatibility shims.
4
+
5
+ ## Main files
6
+
7
+ - [local_policy.py](/Users/aditya/Developer/traffic-llm/agents/local_policy.py)
8
+ Active v1 policy interfaces and simple baselines:
9
+ - `HoldPhasePolicy`
10
+ - `FixedCyclePolicy`
11
+ - `QueueGreedyPolicy`
12
+ - [district_controller.py](/Users/aditya/Developer/traffic-llm/agents/district_controller.py)
13
+ Older district-level prototype logic kept for compatibility.
14
+ - [district_coordinator.py](/Users/aditya/Developer/traffic-llm/agents/district_coordinator.py)
15
+ Import shim for older code paths.
16
+
17
+ ## Notes
18
+
19
+ - The learned local-policy network itself lives in [training/models.py](/Users/aditya/Developer/traffic-llm/training/models.py), not here.
20
+ - For active training, use the parameter-shared DQN path in `training/`, not the district-controller prototypes.
agents/__init__.py ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from agents.local_policy import (
2
+ BaseLocalPolicy,
3
+ FixedCyclePolicy,
4
+ HoldPhasePolicy,
5
+ QueueGreedyPolicy,
6
+ SharedHeuristicLocalPolicy,
7
+ )
8
+
9
+ __all__ = [
10
+ "BaseLocalPolicy",
11
+ "FixedCyclePolicy",
12
+ "HoldPhasePolicy",
13
+ "QueueGreedyPolicy",
14
+ "SharedHeuristicLocalPolicy",
15
+ ]
agents/district_controller.py ADDED
@@ -0,0 +1,187 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ from abc import ABC, abstractmethod
4
+ from typing import Any, Callable
5
+
6
+ from agents.message_protocol import DistrictDirective, parse_district_directive
7
+
8
+
9
+ class BaseDistrictCoordinator(ABC):
10
+ @abstractmethod
11
+ def decide(self, district_summary: dict[str, Any]) -> dict[str, Any]:
12
+ raise NotImplementedError
13
+
14
+
15
+ class RuleBasedDistrictCoordinator(BaseDistrictCoordinator):
16
+ """
17
+ Fast, deterministic, and robust.
18
+ Good first coordinator and good fallback if the LLM output fails.
19
+ """
20
+
21
+ def __init__(
22
+ self,
23
+ imbalance_threshold: float = 0.15,
24
+ border_pressure_threshold: float = 0.65,
25
+ default_duration: int = 2,
26
+ ):
27
+ self.imbalance_threshold = imbalance_threshold
28
+ self.border_pressure_threshold = border_pressure_threshold
29
+ self.default_duration = default_duration
30
+
31
+ def decide(self, district_summary: dict[str, Any]) -> dict[str, Any]:
32
+ district_id = district_summary.get("district_id", "unknown")
33
+ intersection_ids = district_summary.get("intersection_ids", [])
34
+
35
+ emergency = district_summary.get("emergency_vehicle", {})
36
+ if emergency.get("present", False):
37
+ return (
38
+ DistrictDirective(
39
+ mode="emergency_route",
40
+ target_intersections=emergency.get("route", intersection_ids),
41
+ duration=2,
42
+ rationale=f"Emergency vehicle detected in district {district_id}.",
43
+ corridor=emergency.get("corridor"),
44
+ district_weight=1.0,
45
+ )
46
+ .validate()
47
+ .to_dict()
48
+ )
49
+
50
+ corridor_loads = district_summary.get("corridor_loads", {})
51
+ ns = float(corridor_loads.get("ns", corridor_loads.get("north_south", 0.0)))
52
+ ew = float(corridor_loads.get("ew", corridor_loads.get("east_west", 0.0)))
53
+
54
+ border_pressure = district_summary.get("border_pressure", {})
55
+ border_max = 0.0
56
+ if isinstance(border_pressure, dict) and border_pressure:
57
+ border_max = max(float(v) for v in border_pressure.values())
58
+
59
+ if ew - ns > self.imbalance_threshold:
60
+ return (
61
+ DistrictDirective(
62
+ mode="prioritize_ew",
63
+ target_intersections=intersection_ids,
64
+ duration=self.default_duration,
65
+ rationale="East-west corridor is currently more congested than north-south.",
66
+ corridor="ew",
67
+ district_weight=(
68
+ 0.7 if border_max < self.border_pressure_threshold else 0.9
69
+ ),
70
+ )
71
+ .validate()
72
+ .to_dict()
73
+ )
74
+
75
+ if ns - ew > self.imbalance_threshold:
76
+ return (
77
+ DistrictDirective(
78
+ mode="prioritize_ns",
79
+ target_intersections=intersection_ids,
80
+ duration=self.default_duration,
81
+ rationale="North-south corridor is currently more congested than east-west.",
82
+ corridor="ns",
83
+ district_weight=(
84
+ 0.7 if border_max < self.border_pressure_threshold else 0.9
85
+ ),
86
+ )
87
+ .validate()
88
+ .to_dict()
89
+ )
90
+
91
+ if border_max >= self.border_pressure_threshold:
92
+ return (
93
+ DistrictDirective(
94
+ mode="damp_border_inflow",
95
+ target_intersections=intersection_ids,
96
+ duration=2,
97
+ rationale="Border pressure is high; reduce spill-in and smooth cross-district flow.",
98
+ district_weight=0.8,
99
+ )
100
+ .validate()
101
+ .to_dict()
102
+ )
103
+
104
+ return (
105
+ DistrictDirective(
106
+ mode="none",
107
+ target_intersections=[],
108
+ duration=1,
109
+ rationale="District is reasonably balanced.",
110
+ district_weight=0.5,
111
+ )
112
+ .validate()
113
+ .to_dict()
114
+ )
115
+
116
+
117
+ class LLMDistrictCoordinator(BaseDistrictCoordinator):
118
+ """
119
+ LLM-backed coordinator.
120
+
121
+ `generator_fn` should accept a prompt string and return either:
122
+ - a JSON string, or
123
+ - a dict
124
+
125
+ Example:
126
+ coordinator = LLMDistrictCoordinator(generator_fn=my_model_call)
127
+ """
128
+
129
+ def __init__(
130
+ self,
131
+ generator_fn: Callable[[str], str | dict[str, Any]],
132
+ fallback: BaseDistrictCoordinator | None = None,
133
+ max_prompt_chars: int = 4000,
134
+ ):
135
+ self.generator_fn = generator_fn
136
+ self.fallback = fallback or RuleBasedDistrictCoordinator()
137
+ self.max_prompt_chars = max_prompt_chars
138
+
139
+ def decide(self, district_summary: dict[str, Any]) -> dict[str, Any]:
140
+ prompt = self.build_prompt(district_summary)
141
+ try:
142
+ raw = self.generator_fn(prompt)
143
+ directive = parse_district_directive(raw).to_dict()
144
+
145
+ # If the LLM returns a no-op too often or malformed content,
146
+ # the parser still makes it safe. We keep that behavior.
147
+ return directive
148
+ except Exception:
149
+ return self.fallback.decide(district_summary)
150
+
151
+ def build_prompt(self, district_summary: dict[str, Any]) -> str:
152
+ summary_text = repr(district_summary)
153
+ if len(summary_text) > self.max_prompt_chars:
154
+ summary_text = summary_text[: self.max_prompt_chars] + " ...[truncated]"
155
+
156
+ return f"""You are a district-level traffic coordinator.
157
+
158
+ Your job is to choose a single strategic directive for the next few cycles.
159
+
160
+ Allowed modes:
161
+ - none
162
+ - prioritize_ns
163
+ - prioritize_ew
164
+ - green_wave
165
+ - emergency_route
166
+ - damp_border_inflow
167
+
168
+ Return ONLY valid JSON with these fields:
169
+ {{
170
+ "mode": string,
171
+ "target_intersections": list[string],
172
+ "duration": int,
173
+ "rationale": string,
174
+ "corridor": string or null,
175
+ "district_weight": float
176
+ }}
177
+
178
+ Guidelines:
179
+ - Use emergency_route if an emergency vehicle is present.
180
+ - Use prioritize_ns or prioritize_ew when one corridor is clearly more congested.
181
+ - Use damp_border_inflow when cross-district border pressure is high.
182
+ - Keep duration between 1 and 5.
183
+ - district_weight should be between 0.0 and 1.0.
184
+
185
+ District summary:
186
+ {summary_text}
187
+ """
agents/district_coordinator.py ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from agents.district_controller import (
2
+ BaseDistrictCoordinator,
3
+ LLMDistrictCoordinator,
4
+ RuleBasedDistrictCoordinator,
5
+ )
6
+
7
+ __all__ = [
8
+ "BaseDistrictCoordinator",
9
+ "LLMDistrictCoordinator",
10
+ "RuleBasedDistrictCoordinator",
11
+ ]
agents/heuristic_controller.py ADDED
@@ -0,0 +1,91 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ from typing import Any
4
+
5
+
6
+ class HeuristicController:
7
+ """
8
+ Simple local traffic-light controller.
9
+
10
+ Action space:
11
+ 0 -> choose NS green
12
+ 1 -> choose EW green
13
+
14
+ Assumes:
15
+ queue_lengths = [N, S, E, W]
16
+ waiting_counts = [N, S, E, W]
17
+ """
18
+
19
+ def __init__(
20
+ self,
21
+ min_green_steps: int = 5,
22
+ switch_margin: float = 1.0,
23
+ district_bonus_scale: float = 3.0,
24
+ neighbor_pressure_scale: float = 0.25,
25
+ ):
26
+ self.min_green_steps = min_green_steps
27
+ self.switch_margin = switch_margin
28
+ self.district_bonus_scale = district_bonus_scale
29
+ self.neighbor_pressure_scale = neighbor_pressure_scale
30
+
31
+ def act(self, obs: dict[str, Any]) -> int:
32
+ queue_lengths = obs.get("queue_lengths", [0, 0, 0, 0])
33
+ waiting_counts = obs.get("waiting_counts", [0, 0, 0, 0])
34
+ current_phase = int(obs.get("current_phase", 0))
35
+ time_since_switch = int(obs.get("time_since_switch", 0))
36
+ district_mode = obs.get("district_mode", "none")
37
+ district_weight = float(obs.get("district_weight", 0.5))
38
+ neighbor_pressure = obs.get("neighbor_pressure", [0.0, 0.0])
39
+
40
+ ns_score = (
41
+ queue_lengths[0]
42
+ + queue_lengths[1]
43
+ + 1.5 * (waiting_counts[0] + waiting_counts[1])
44
+ )
45
+ ew_score = (
46
+ queue_lengths[2]
47
+ + queue_lengths[3]
48
+ + 1.5 * (waiting_counts[2] + waiting_counts[3])
49
+ )
50
+
51
+ # Optional small neighbor-pressure bias
52
+ if isinstance(neighbor_pressure, list) and len(neighbor_pressure) >= 2:
53
+ ns_score += self.neighbor_pressure_scale * float(neighbor_pressure[0])
54
+ ew_score += self.neighbor_pressure_scale * float(neighbor_pressure[1])
55
+
56
+ # District-level strategic bias
57
+ district_bonus = self.district_bonus_scale * district_weight
58
+ if district_mode == "prioritize_ns":
59
+ ns_score += district_bonus
60
+ elif district_mode == "prioritize_ew":
61
+ ew_score += district_bonus
62
+ elif district_mode == "green_wave":
63
+ corridor = obs.get("district_corridor")
64
+ if corridor == "ns":
65
+ ns_score += district_bonus
66
+ elif corridor == "ew":
67
+ ew_score += district_bonus
68
+ elif district_mode == "emergency_route":
69
+ corridor = obs.get("district_corridor")
70
+ if corridor in {"north_to_south", "south_to_north", "ns"}:
71
+ ns_score += district_bonus * 1.5
72
+ elif corridor in {"west_to_east", "east_to_west", "ew"}:
73
+ ew_score += district_bonus * 1.5
74
+
75
+ desired_phase = 0 if ns_score >= ew_score else 1
76
+
77
+ # Avoid thrashing
78
+ if time_since_switch < self.min_green_steps:
79
+ return current_phase
80
+
81
+ # Only switch if the other phase is meaningfully better
82
+ current_score = ns_score if current_phase == 0 else ew_score
83
+ desired_score = ns_score if desired_phase == 0 else ew_score
84
+
85
+ if (
86
+ desired_phase != current_phase
87
+ and desired_score < current_score + self.switch_margin
88
+ ):
89
+ return current_phase
90
+
91
+ return desired_phase
agents/local_policy.py ADDED
@@ -0,0 +1,110 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ from abc import ABC, abstractmethod
4
+
5
+ import numpy as np
6
+
7
+
8
+ class BaseLocalPolicy(ABC):
9
+ @abstractmethod
10
+ def act(self, observation_batch: dict[str, np.ndarray]) -> np.ndarray:
11
+ raise NotImplementedError
12
+
13
+
14
+ class HoldPhasePolicy(BaseLocalPolicy):
15
+ def act(self, observation_batch: dict[str, np.ndarray]) -> np.ndarray:
16
+ intersection_count = len(observation_batch["intersection_ids"])
17
+ return np.zeros(intersection_count, dtype=np.int64)
18
+
19
+
20
+ class RandomPhasePolicy(BaseLocalPolicy):
21
+ def __init__(self, seed: int = 7):
22
+ self.rng = np.random.default_rng(seed)
23
+
24
+ def act(self, observation_batch: dict[str, np.ndarray]) -> np.ndarray:
25
+ action_mask = observation_batch["action_mask"]
26
+ actions = np.zeros(action_mask.shape[0], dtype=np.int64)
27
+ for row_index, mask in enumerate(action_mask):
28
+ valid_actions = np.flatnonzero(mask > 0.0)
29
+ actions[row_index] = int(self.rng.choice(valid_actions))
30
+ return actions
31
+
32
+
33
+ class FixedCyclePolicy(BaseLocalPolicy):
34
+ def __init__(self, green_time: int = 20):
35
+ self.green_time = int(green_time)
36
+
37
+ def act(self, observation_batch: dict[str, np.ndarray]) -> np.ndarray:
38
+ elapsed = observation_batch["phase_elapsed"]
39
+ action_mask = observation_batch["action_mask"]
40
+ should_switch = (elapsed >= self.green_time) & (action_mask[:, 1] > 0.0)
41
+ return should_switch.astype(np.int64)
42
+
43
+
44
+ class QueueGreedyPolicy(BaseLocalPolicy):
45
+ def __init__(self, switch_margin: float = 1.0):
46
+ self.switch_margin = float(switch_margin)
47
+
48
+ def act(self, observation_batch: dict[str, np.ndarray]) -> np.ndarray:
49
+ counts = observation_batch["incoming_counts"]
50
+ waiting = observation_batch["incoming_waiting"]
51
+ lane_mask = observation_batch["lane_mask"]
52
+ current_phase = observation_batch["current_phase"]
53
+ action_mask = observation_batch["action_mask"]
54
+
55
+ midpoint = counts.shape[1] // 2
56
+ ns_score = (
57
+ counts[:, :midpoint].sum(axis=1)
58
+ + 1.5 * waiting[:, :midpoint].sum(axis=1)
59
+ )
60
+ ew_score = (
61
+ counts[:, midpoint:].sum(axis=1)
62
+ + 1.5 * waiting[:, midpoint:].sum(axis=1)
63
+ )
64
+
65
+ valid_midpoint = lane_mask[:, :midpoint].sum(axis=1) > 0
66
+ ns_score = np.where(valid_midpoint, ns_score, 0.0)
67
+
68
+ desired_switch = np.where(
69
+ current_phase == 0,
70
+ ew_score > ns_score + self.switch_margin,
71
+ ns_score > ew_score + self.switch_margin,
72
+ )
73
+ desired_switch = desired_switch & (action_mask[:, 1] > 0.0)
74
+ return desired_switch.astype(np.int64)
75
+
76
+
77
+ class SharedHeuristicLocalPolicy(QueueGreedyPolicy):
78
+ def __init__(
79
+ self,
80
+ min_green_steps: int = 5,
81
+ switch_margin: float = 1.0,
82
+ district_bonus_scale: float = 0.0,
83
+ neighbor_pressure_scale: float = 0.0,
84
+ ):
85
+ self.min_green_steps = int(min_green_steps)
86
+ del district_bonus_scale, neighbor_pressure_scale
87
+ super().__init__(switch_margin=switch_margin)
88
+
89
+ def act_batch(self, observation_batch):
90
+ if "intersection_ids" in observation_batch:
91
+ return self.act(observation_batch)
92
+
93
+ actions: dict[str, int] = {}
94
+ for intersection_id, payload in observation_batch.items():
95
+ waiting = payload.get("waiting_counts", [0, 0, 0, 0])
96
+ queues = payload.get("queue_lengths", [0, 0, 0, 0])
97
+ current_phase = int(payload.get("current_phase", 0))
98
+ time_since_switch = int(payload.get("time_since_switch", 0))
99
+
100
+ ns_score = float(sum(queues[:2]) + 1.5 * sum(waiting[:2]))
101
+ ew_score = float(sum(queues[2:4]) + 1.5 * sum(waiting[2:4]))
102
+ desired_phase = 0 if ns_score >= ew_score else 1
103
+
104
+ if time_since_switch < self.min_green_steps:
105
+ actions[intersection_id] = current_phase
106
+ elif desired_phase != current_phase and abs(ns_score - ew_score) <= self.switch_margin:
107
+ actions[intersection_id] = current_phase
108
+ else:
109
+ actions[intersection_id] = desired_phase
110
+ return actions
agents/message_protocol.py ADDED
@@ -0,0 +1,116 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from __future__ import annotations
2
+
3
+ import json
4
+ from dataclasses import asdict, dataclass, field
5
+ from typing import Any
6
+
7
+
8
+ VALID_MODES = {
9
+ "none",
10
+ "prioritize_ns",
11
+ "prioritize_ew",
12
+ "green_wave",
13
+ "emergency_route",
14
+ "damp_border_inflow",
15
+ }
16
+
17
+
18
+ @dataclass
19
+ class NeighborMessage:
20
+ sender_intersection: str
21
+ receiver_intersection: str
22
+ congestion_level: float
23
+ spillback_risk: bool
24
+ dominant_direction: str # "ns", "ew", or "balanced"
25
+ queue_total: int
26
+
27
+ def to_dict(self) -> dict[str, Any]:
28
+ return asdict(self)
29
+
30
+
31
+ @dataclass
32
+ class DistrictDirective:
33
+ mode: str = "none"
34
+ target_intersections: list[str] = field(default_factory=list)
35
+ duration: int = 1
36
+ rationale: str = ""
37
+ corridor: str | None = None
38
+ district_weight: float = 0.5
39
+
40
+ def validate(self) -> "DistrictDirective":
41
+ if self.mode not in VALID_MODES:
42
+ self.mode = "none"
43
+
44
+ if not isinstance(self.target_intersections, list):
45
+ self.target_intersections = []
46
+
47
+ if not isinstance(self.duration, int):
48
+ self.duration = 1
49
+ self.duration = max(1, min(self.duration, 10))
50
+
51
+ if not isinstance(self.rationale, str):
52
+ self.rationale = ""
53
+
54
+ if self.corridor is not None and self.corridor not in {
55
+ "ns",
56
+ "ew",
57
+ "west_to_east",
58
+ "east_to_west",
59
+ "north_to_south",
60
+ "south_to_north",
61
+ }:
62
+ self.corridor = None
63
+
64
+ if not isinstance(self.district_weight, (int, float)):
65
+ self.district_weight = 0.5
66
+ self.district_weight = float(max(0.0, min(1.0, self.district_weight)))
67
+
68
+ return self
69
+
70
+ def to_dict(self) -> dict[str, Any]:
71
+ return asdict(self)
72
+
73
+
74
+ def parse_district_directive(payload: str | dict[str, Any]) -> DistrictDirective:
75
+ """
76
+ Accept either raw JSON text or a dict and return a validated DistrictDirective.
77
+ Falls back safely to a no-op directive.
78
+ """
79
+ try:
80
+ if isinstance(payload, str):
81
+ payload = payload.strip()
82
+ if not payload:
83
+ return DistrictDirective().validate()
84
+
85
+ # Try direct JSON parse
86
+ try:
87
+ data = json.loads(payload)
88
+ except json.JSONDecodeError:
89
+ # Try to extract JSON object from surrounding text
90
+ start = payload.find("{")
91
+ end = payload.rfind("}")
92
+ if start == -1 or end == -1 or end <= start:
93
+ return DistrictDirective().validate()
94
+ data = json.loads(payload[start : end + 1])
95
+ elif isinstance(payload, dict):
96
+ data = payload
97
+ else:
98
+ return DistrictDirective().validate()
99
+
100
+ directive = DistrictDirective(
101
+ mode=data.get("mode", "none"),
102
+ target_intersections=data.get("target_intersections", []),
103
+ duration=data.get("duration", 1),
104
+ rationale=data.get("rationale", ""),
105
+ corridor=data.get("corridor"),
106
+ district_weight=data.get("district_weight", 0.5),
107
+ )
108
+ return directive.validate()
109
+ except Exception:
110
+ return DistrictDirective().validate()
111
+
112
+
113
+ def safe_directive_dict(payload: str | dict[str, Any] | None) -> dict[str, Any]:
114
+ if payload is None:
115
+ return DistrictDirective().validate().to_dict()
116
+ return parse_district_directive(payload).to_dict()
artifacts/README.md ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ # Artifacts
2
+
3
+ For our 3rd iteration of district LLM, 150 is the best.
artifacts/district_llm_adapter_v2/README.md ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ base_model: unsloth/llama-3.1-8b-unsloth-bnb-4bit
3
+ library_name: peft
4
+ model_name: district_llm_adapter_v2
5
+ tags:
6
+ - base_model:adapter:unsloth/llama-3.1-8b-unsloth-bnb-4bit
7
+ - lora
8
+ - sft
9
+ - transformers
10
+ - trl
11
+ - unsloth
12
+ licence: license
13
+ pipeline_tag: text-generation
14
+ ---
15
+
16
+ # Model Card for district_llm_adapter_v2
17
+
18
+ This model is a fine-tuned version of [unsloth/llama-3.1-8b-unsloth-bnb-4bit](https://huggingface.co/unsloth/llama-3.1-8b-unsloth-bnb-4bit).
19
+ It has been trained using [TRL](https://github.com/huggingface/trl).
20
+
21
+ ## Quick start
22
+
23
+ ```python
24
+ from transformers import pipeline
25
+
26
+ question = "If you had a time machine, but could only go to the past or the future once and never return, which would you choose and why?"
27
+ generator = pipeline("text-generation", model="None", device="cuda")
28
+ output = generator([{"role": "user", "content": question}], max_new_tokens=128, return_full_text=False)[0]
29
+ print(output["generated_text"])
30
+ ```
31
+
32
+ ## Training procedure
33
+
34
+
35
+
36
+
37
+ This model was trained with SFT.
38
+
39
+ ### Framework versions
40
+
41
+ - PEFT 0.18.1
42
+ - TRL: 0.24.0
43
+ - Transformers: 5.2.0
44
+ - Pytorch: 2.10.0
45
+ - Datasets: 4.3.0
46
+ - Tokenizers: 0.22.2
47
+
48
+ ## Citations
49
+
50
+
51
+
52
+ Cite TRL as:
53
+
54
+ ```bibtex
55
+ @misc{vonwerra2022trl,
56
+ title = {{TRL: Transformer Reinforcement Learning}},
57
+ author = {Leandro von Werra and Younes Belkada and Lewis Tunstall and Edward Beeching and Tristan Thrush and Nathan Lambert and Shengyi Huang and Kashif Rasul and Quentin Gallou{\'e}dec},
58
+ year = 2020,
59
+ journal = {GitHub repository},
60
+ publisher = {GitHub},
61
+ howpublished = {\url{https://github.com/huggingface/trl}}
62
+ }
63
+ ```
artifacts/district_llm_adapter_v2/adapter_config.json ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "alora_invocation_tokens": null,
3
+ "alpha_pattern": {},
4
+ "arrow_config": null,
5
+ "auto_mapping": {
6
+ "base_model_class": "LlamaForCausalLM",
7
+ "parent_library": "transformers.models.llama.modeling_llama",
8
+ "unsloth_fixed": true
9
+ },
10
+ "base_model_name_or_path": "unsloth/llama-3.1-8b-unsloth-bnb-4bit",
11
+ "bias": "none",
12
+ "corda_config": null,
13
+ "ensure_weight_tying": false,
14
+ "eva_config": null,
15
+ "exclude_modules": null,
16
+ "fan_in_fan_out": false,
17
+ "inference_mode": true,
18
+ "init_lora_weights": true,
19
+ "layer_replication": null,
20
+ "layers_pattern": null,
21
+ "layers_to_transform": null,
22
+ "loftq_config": {},
23
+ "lora_alpha": 16,
24
+ "lora_bias": false,
25
+ "lora_dropout": 0,
26
+ "megatron_config": null,
27
+ "megatron_core": "megatron.core",
28
+ "modules_to_save": null,
29
+ "peft_type": "LORA",
30
+ "peft_version": "0.18.1",
31
+ "qalora_group_size": 16,
32
+ "r": 16,
33
+ "rank_pattern": {},
34
+ "revision": null,
35
+ "target_modules": [
36
+ "down_proj",
37
+ "up_proj",
38
+ "q_proj",
39
+ "k_proj",
40
+ "v_proj",
41
+ "o_proj",
42
+ "gate_proj"
43
+ ],
44
+ "target_parameters": null,
45
+ "task_type": "CAUSAL_LM",
46
+ "trainable_token_indices": null,
47
+ "use_dora": false,
48
+ "use_qalora": false,
49
+ "use_rslora": false
50
+ }
artifacts/district_llm_adapter_v2/adapter_model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:18e9b835a17a3b1429550ea5e4afaa9b8ecc9301da476f35ece0679c9fb0203a
3
+ size 167832240
artifacts/district_llm_adapter_v2/checkpoint-100/README.md ADDED
@@ -0,0 +1,210 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ base_model: unsloth/llama-3.1-8b-unsloth-bnb-4bit
3
+ library_name: peft
4
+ pipeline_tag: text-generation
5
+ tags:
6
+ - base_model:adapter:unsloth/llama-3.1-8b-unsloth-bnb-4bit
7
+ - lora
8
+ - sft
9
+ - transformers
10
+ - trl
11
+ - unsloth
12
+ ---
13
+
14
+ # Model Card for Model ID
15
+
16
+ <!-- Provide a quick summary of what the model is/does. -->
17
+
18
+
19
+
20
+ ## Model Details
21
+
22
+ ### Model Description
23
+
24
+ <!-- Provide a longer summary of what this model is. -->
25
+
26
+
27
+
28
+ - **Developed by:** [More Information Needed]
29
+ - **Funded by [optional]:** [More Information Needed]
30
+ - **Shared by [optional]:** [More Information Needed]
31
+ - **Model type:** [More Information Needed]
32
+ - **Language(s) (NLP):** [More Information Needed]
33
+ - **License:** [More Information Needed]
34
+ - **Finetuned from model [optional]:** [More Information Needed]
35
+
36
+ ### Model Sources [optional]
37
+
38
+ <!-- Provide the basic links for the model. -->
39
+
40
+ - **Repository:** [More Information Needed]
41
+ - **Paper [optional]:** [More Information Needed]
42
+ - **Demo [optional]:** [More Information Needed]
43
+
44
+ ## Uses
45
+
46
+ <!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
47
+
48
+ ### Direct Use
49
+
50
+ <!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
51
+
52
+ [More Information Needed]
53
+
54
+ ### Downstream Use [optional]
55
+
56
+ <!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
57
+
58
+ [More Information Needed]
59
+
60
+ ### Out-of-Scope Use
61
+
62
+ <!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
63
+
64
+ [More Information Needed]
65
+
66
+ ## Bias, Risks, and Limitations
67
+
68
+ <!-- This section is meant to convey both technical and sociotechnical limitations. -->
69
+
70
+ [More Information Needed]
71
+
72
+ ### Recommendations
73
+
74
+ <!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
75
+
76
+ Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
77
+
78
+ ## How to Get Started with the Model
79
+
80
+ Use the code below to get started with the model.
81
+
82
+ [More Information Needed]
83
+
84
+ ## Training Details
85
+
86
+ ### Training Data
87
+
88
+ <!-- This should link to a Dataset Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering. -->
89
+
90
+ [More Information Needed]
91
+
92
+ ### Training Procedure
93
+
94
+ <!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
95
+
96
+ #### Preprocessing [optional]
97
+
98
+ [More Information Needed]
99
+
100
+
101
+ #### Training Hyperparameters
102
+
103
+ - **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
104
+
105
+ #### Speeds, Sizes, Times [optional]
106
+
107
+ <!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
108
+
109
+ [More Information Needed]
110
+
111
+ ## Evaluation
112
+
113
+ <!-- This section describes the evaluation protocols and provides the results. -->
114
+
115
+ ### Testing Data, Factors & Metrics
116
+
117
+ #### Testing Data
118
+
119
+ <!-- This should link to a Dataset Card if possible. -->
120
+
121
+ [More Information Needed]
122
+
123
+ #### Factors
124
+
125
+ <!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
126
+
127
+ [More Information Needed]
128
+
129
+ #### Metrics
130
+
131
+ <!-- These are the evaluation metrics being used, ideally with a description of why. -->
132
+
133
+ [More Information Needed]
134
+
135
+ ### Results
136
+
137
+ [More Information Needed]
138
+
139
+ #### Summary
140
+
141
+
142
+
143
+ ## Model Examination [optional]
144
+
145
+ <!-- Relevant interpretability work for the model goes here -->
146
+
147
+ [More Information Needed]
148
+
149
+ ## Environmental Impact
150
+
151
+ <!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
152
+
153
+ Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
154
+
155
+ - **Hardware Type:** [More Information Needed]
156
+ - **Hours used:** [More Information Needed]
157
+ - **Cloud Provider:** [More Information Needed]
158
+ - **Compute Region:** [More Information Needed]
159
+ - **Carbon Emitted:** [More Information Needed]
160
+
161
+ ## Technical Specifications [optional]
162
+
163
+ ### Model Architecture and Objective
164
+
165
+ [More Information Needed]
166
+
167
+ ### Compute Infrastructure
168
+
169
+ [More Information Needed]
170
+
171
+ #### Hardware
172
+
173
+ [More Information Needed]
174
+
175
+ #### Software
176
+
177
+ [More Information Needed]
178
+
179
+ ## Citation [optional]
180
+
181
+ <!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
182
+
183
+ **BibTeX:**
184
+
185
+ [More Information Needed]
186
+
187
+ **APA:**
188
+
189
+ [More Information Needed]
190
+
191
+ ## Glossary [optional]
192
+
193
+ <!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
194
+
195
+ [More Information Needed]
196
+
197
+ ## More Information [optional]
198
+
199
+ [More Information Needed]
200
+
201
+ ## Model Card Authors [optional]
202
+
203
+ [More Information Needed]
204
+
205
+ ## Model Card Contact
206
+
207
+ [More Information Needed]
208
+ ### Framework versions
209
+
210
+ - PEFT 0.18.1
artifacts/district_llm_adapter_v2/checkpoint-100/adapter_config.json ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "alora_invocation_tokens": null,
3
+ "alpha_pattern": {},
4
+ "arrow_config": null,
5
+ "auto_mapping": {
6
+ "base_model_class": "LlamaForCausalLM",
7
+ "parent_library": "transformers.models.llama.modeling_llama",
8
+ "unsloth_fixed": true
9
+ },
10
+ "base_model_name_or_path": "unsloth/llama-3.1-8b-unsloth-bnb-4bit",
11
+ "bias": "none",
12
+ "corda_config": null,
13
+ "ensure_weight_tying": false,
14
+ "eva_config": null,
15
+ "exclude_modules": null,
16
+ "fan_in_fan_out": false,
17
+ "inference_mode": true,
18
+ "init_lora_weights": true,
19
+ "layer_replication": null,
20
+ "layers_pattern": null,
21
+ "layers_to_transform": null,
22
+ "loftq_config": {},
23
+ "lora_alpha": 16,
24
+ "lora_bias": false,
25
+ "lora_dropout": 0,
26
+ "megatron_config": null,
27
+ "megatron_core": "megatron.core",
28
+ "modules_to_save": null,
29
+ "peft_type": "LORA",
30
+ "peft_version": "0.18.1",
31
+ "qalora_group_size": 16,
32
+ "r": 16,
33
+ "rank_pattern": {},
34
+ "revision": null,
35
+ "target_modules": [
36
+ "down_proj",
37
+ "up_proj",
38
+ "q_proj",
39
+ "k_proj",
40
+ "v_proj",
41
+ "o_proj",
42
+ "gate_proj"
43
+ ],
44
+ "target_parameters": null,
45
+ "task_type": "CAUSAL_LM",
46
+ "trainable_token_indices": null,
47
+ "use_dora": false,
48
+ "use_qalora": false,
49
+ "use_rslora": false
50
+ }
artifacts/district_llm_adapter_v2/checkpoint-100/adapter_model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:ccc17edb05ab2ceffb808c495859a48e7eb78507264a0404bc0aa2cda8eab3f3
3
+ size 167832240
artifacts/district_llm_adapter_v2/checkpoint-100/optimizer.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b0e7cf928e3b2955b39d6a9e5b96926f624d9f53efd6b1703fdc8658bd792b5a
3
+ size 85728229
artifacts/district_llm_adapter_v2/checkpoint-100/rng_state.pth ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7c800b778fa7e115e4c34de8529902de8b61c9a1b4bab3eb8295d06dafff030e
3
+ size 14645
artifacts/district_llm_adapter_v2/checkpoint-100/scheduler.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:5f48b2993192172e90d469975ad49cfb293d165a9bc6f65da704bfab6cd3cab3
3
+ size 1465
artifacts/district_llm_adapter_v2/checkpoint-100/tokenizer.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6b9e4e7fb171f92fd137b777cc2714bf87d11576700a1dcd7a399e7bbe39537b
3
+ size 17209920
artifacts/district_llm_adapter_v2/checkpoint-100/tokenizer_config.json ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "backend": "tokenizers",
3
+ "bos_token": "<|begin_of_text|>",
4
+ "clean_up_tokenization_spaces": true,
5
+ "eos_token": "<|end_of_text|>",
6
+ "from_slow": true,
7
+ "is_local": false,
8
+ "legacy": false,
9
+ "model_input_names": [
10
+ "input_ids",
11
+ "attention_mask"
12
+ ],
13
+ "model_max_length": 131072,
14
+ "pad_token": "<|finetune_right_pad_id|>",
15
+ "padding_side": "right",
16
+ "tokenizer_class": "TokenizersBackend",
17
+ "unk_token": null
18
+ }
artifacts/district_llm_adapter_v2/checkpoint-100/trainer_state.json ADDED
@@ -0,0 +1,174 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "best_global_step": null,
3
+ "best_metric": null,
4
+ "best_model_checkpoint": null,
5
+ "epoch": 0.5333333333333333,
6
+ "eval_steps": 50,
7
+ "global_step": 100,
8
+ "is_hyper_param_search": false,
9
+ "is_local_process_zero": true,
10
+ "is_world_process_zero": true,
11
+ "log_history": [
12
+ {
13
+ "epoch": 0.02666666666666667,
14
+ "grad_norm": 0.824774444103241,
15
+ "learning_rate": 4e-05,
16
+ "loss": 1.4378397941589356,
17
+ "step": 5
18
+ },
19
+ {
20
+ "epoch": 0.05333333333333334,
21
+ "grad_norm": 1.7167983055114746,
22
+ "learning_rate": 9e-05,
23
+ "loss": 1.087998867034912,
24
+ "step": 10
25
+ },
26
+ {
27
+ "epoch": 0.08,
28
+ "grad_norm": 0.7535544037818909,
29
+ "learning_rate": 0.00014,
30
+ "loss": 0.5613192558288574,
31
+ "step": 15
32
+ },
33
+ {
34
+ "epoch": 0.10666666666666667,
35
+ "grad_norm": 0.6983357071876526,
36
+ "learning_rate": 0.00019,
37
+ "loss": 0.28872098922729494,
38
+ "step": 20
39
+ },
40
+ {
41
+ "epoch": 0.13333333333333333,
42
+ "grad_norm": 0.8250440955162048,
43
+ "learning_rate": 0.00019989930665413147,
44
+ "loss": 0.22604494094848632,
45
+ "step": 25
46
+ },
47
+ {
48
+ "epoch": 0.16,
49
+ "grad_norm": 0.26267266273498535,
50
+ "learning_rate": 0.00019949058745487522,
51
+ "loss": 0.20742559432983398,
52
+ "step": 30
53
+ },
54
+ {
55
+ "epoch": 0.18666666666666668,
56
+ "grad_norm": 0.27337217330932617,
57
+ "learning_rate": 0.00019876883405951377,
58
+ "loss": 0.1870889902114868,
59
+ "step": 35
60
+ },
61
+ {
62
+ "epoch": 0.21333333333333335,
63
+ "grad_norm": 0.10534920543432236,
64
+ "learning_rate": 0.00019773631737125192,
65
+ "loss": 0.18097405433654784,
66
+ "step": 40
67
+ },
68
+ {
69
+ "epoch": 0.24,
70
+ "grad_norm": 0.13477347791194916,
71
+ "learning_rate": 0.00019639628606958533,
72
+ "loss": 0.17958487272262574,
73
+ "step": 45
74
+ },
75
+ {
76
+ "epoch": 0.26666666666666666,
77
+ "grad_norm": 0.1370360553264618,
78
+ "learning_rate": 0.0001947529563887529,
79
+ "loss": 0.16803257465362548,
80
+ "step": 50
81
+ },
82
+ {
83
+ "epoch": 0.29333333333333333,
84
+ "grad_norm": 0.1513640433549881,
85
+ "learning_rate": 0.0001928114988519039,
86
+ "loss": 0.16801449060440063,
87
+ "step": 55
88
+ },
89
+ {
90
+ "epoch": 0.32,
91
+ "grad_norm": 0.11957086622714996,
92
+ "learning_rate": 0.00019057802200271942,
93
+ "loss": 0.16269906759262084,
94
+ "step": 60
95
+ },
96
+ {
97
+ "epoch": 0.3466666666666667,
98
+ "grad_norm": 0.11077677458524704,
99
+ "learning_rate": 0.0001880595531856738,
100
+ "loss": 0.16706794500350952,
101
+ "step": 65
102
+ },
103
+ {
104
+ "epoch": 0.37333333333333335,
105
+ "grad_norm": 0.10614161193370819,
106
+ "learning_rate": 0.00018526401643540922,
107
+ "loss": 0.16436902284622193,
108
+ "step": 70
109
+ },
110
+ {
111
+ "epoch": 0.4,
112
+ "grad_norm": 0.13366934657096863,
113
+ "learning_rate": 0.00018220020754479102,
114
+ "loss": 0.15710221529006957,
115
+ "step": 75
116
+ },
117
+ {
118
+ "epoch": 0.4266666666666667,
119
+ "grad_norm": 0.1160494014620781,
120
+ "learning_rate": 0.00017887776639008914,
121
+ "loss": 0.16149884462356567,
122
+ "step": 80
123
+ },
124
+ {
125
+ "epoch": 0.4533333333333333,
126
+ "grad_norm": 0.09502895176410675,
127
+ "learning_rate": 0.00017530714660036112,
128
+ "loss": 0.16155229806900023,
129
+ "step": 85
130
+ },
131
+ {
132
+ "epoch": 0.48,
133
+ "grad_norm": 0.11183392256498337,
134
+ "learning_rate": 0.00017149958266646754,
135
+ "loss": 0.15782997608184815,
136
+ "step": 90
137
+ },
138
+ {
139
+ "epoch": 0.5066666666666667,
140
+ "grad_norm": 0.11126931011676788,
141
+ "learning_rate": 0.00016746705459320745,
142
+ "loss": 0.1604154586791992,
143
+ "step": 95
144
+ },
145
+ {
146
+ "epoch": 0.5333333333333333,
147
+ "grad_norm": 0.0941988080739975,
148
+ "learning_rate": 0.00016322225020579099,
149
+ "loss": 0.15799541473388673,
150
+ "step": 100
151
+ }
152
+ ],
153
+ "logging_steps": 5,
154
+ "max_steps": 300,
155
+ "num_input_tokens_seen": 0,
156
+ "num_train_epochs": 2,
157
+ "save_steps": 50,
158
+ "stateful_callbacks": {
159
+ "TrainerControl": {
160
+ "args": {
161
+ "should_epoch_stop": false,
162
+ "should_evaluate": false,
163
+ "should_log": false,
164
+ "should_save": true,
165
+ "should_training_stop": false
166
+ },
167
+ "attributes": {}
168
+ }
169
+ },
170
+ "total_flos": 3.3346529297301504e+16,
171
+ "train_batch_size": 2,
172
+ "trial_name": null,
173
+ "trial_params": null
174
+ }
artifacts/district_llm_adapter_v2/checkpoint-100/training_args.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:99acc664411451a603c8908d063cb9b0bf85f277436eb270d65909aea5df4002
3
+ size 5777
artifacts/district_llm_adapter_v2/checkpoint-150/README.md ADDED
@@ -0,0 +1,210 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ base_model: unsloth/llama-3.1-8b-unsloth-bnb-4bit
3
+ library_name: peft
4
+ pipeline_tag: text-generation
5
+ tags:
6
+ - base_model:adapter:unsloth/llama-3.1-8b-unsloth-bnb-4bit
7
+ - lora
8
+ - sft
9
+ - transformers
10
+ - trl
11
+ - unsloth
12
+ ---
13
+
14
+ # Model Card for Model ID
15
+
16
+ <!-- Provide a quick summary of what the model is/does. -->
17
+
18
+
19
+
20
+ ## Model Details
21
+
22
+ ### Model Description
23
+
24
+ <!-- Provide a longer summary of what this model is. -->
25
+
26
+
27
+
28
+ - **Developed by:** [More Information Needed]
29
+ - **Funded by [optional]:** [More Information Needed]
30
+ - **Shared by [optional]:** [More Information Needed]
31
+ - **Model type:** [More Information Needed]
32
+ - **Language(s) (NLP):** [More Information Needed]
33
+ - **License:** [More Information Needed]
34
+ - **Finetuned from model [optional]:** [More Information Needed]
35
+
36
+ ### Model Sources [optional]
37
+
38
+ <!-- Provide the basic links for the model. -->
39
+
40
+ - **Repository:** [More Information Needed]
41
+ - **Paper [optional]:** [More Information Needed]
42
+ - **Demo [optional]:** [More Information Needed]
43
+
44
+ ## Uses
45
+
46
+ <!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
47
+
48
+ ### Direct Use
49
+
50
+ <!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
51
+
52
+ [More Information Needed]
53
+
54
+ ### Downstream Use [optional]
55
+
56
+ <!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
57
+
58
+ [More Information Needed]
59
+
60
+ ### Out-of-Scope Use
61
+
62
+ <!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
63
+
64
+ [More Information Needed]
65
+
66
+ ## Bias, Risks, and Limitations
67
+
68
+ <!-- This section is meant to convey both technical and sociotechnical limitations. -->
69
+
70
+ [More Information Needed]
71
+
72
+ ### Recommendations
73
+
74
+ <!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
75
+
76
+ Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
77
+
78
+ ## How to Get Started with the Model
79
+
80
+ Use the code below to get started with the model.
81
+
82
+ [More Information Needed]
83
+
84
+ ## Training Details
85
+
86
+ ### Training Data
87
+
88
+ <!-- This should link to a Dataset Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering. -->
89
+
90
+ [More Information Needed]
91
+
92
+ ### Training Procedure
93
+
94
+ <!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
95
+
96
+ #### Preprocessing [optional]
97
+
98
+ [More Information Needed]
99
+
100
+
101
+ #### Training Hyperparameters
102
+
103
+ - **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
104
+
105
+ #### Speeds, Sizes, Times [optional]
106
+
107
+ <!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
108
+
109
+ [More Information Needed]
110
+
111
+ ## Evaluation
112
+
113
+ <!-- This section describes the evaluation protocols and provides the results. -->
114
+
115
+ ### Testing Data, Factors & Metrics
116
+
117
+ #### Testing Data
118
+
119
+ <!-- This should link to a Dataset Card if possible. -->
120
+
121
+ [More Information Needed]
122
+
123
+ #### Factors
124
+
125
+ <!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
126
+
127
+ [More Information Needed]
128
+
129
+ #### Metrics
130
+
131
+ <!-- These are the evaluation metrics being used, ideally with a description of why. -->
132
+
133
+ [More Information Needed]
134
+
135
+ ### Results
136
+
137
+ [More Information Needed]
138
+
139
+ #### Summary
140
+
141
+
142
+
143
+ ## Model Examination [optional]
144
+
145
+ <!-- Relevant interpretability work for the model goes here -->
146
+
147
+ [More Information Needed]
148
+
149
+ ## Environmental Impact
150
+
151
+ <!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
152
+
153
+ Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
154
+
155
+ - **Hardware Type:** [More Information Needed]
156
+ - **Hours used:** [More Information Needed]
157
+ - **Cloud Provider:** [More Information Needed]
158
+ - **Compute Region:** [More Information Needed]
159
+ - **Carbon Emitted:** [More Information Needed]
160
+
161
+ ## Technical Specifications [optional]
162
+
163
+ ### Model Architecture and Objective
164
+
165
+ [More Information Needed]
166
+
167
+ ### Compute Infrastructure
168
+
169
+ [More Information Needed]
170
+
171
+ #### Hardware
172
+
173
+ [More Information Needed]
174
+
175
+ #### Software
176
+
177
+ [More Information Needed]
178
+
179
+ ## Citation [optional]
180
+
181
+ <!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
182
+
183
+ **BibTeX:**
184
+
185
+ [More Information Needed]
186
+
187
+ **APA:**
188
+
189
+ [More Information Needed]
190
+
191
+ ## Glossary [optional]
192
+
193
+ <!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
194
+
195
+ [More Information Needed]
196
+
197
+ ## More Information [optional]
198
+
199
+ [More Information Needed]
200
+
201
+ ## Model Card Authors [optional]
202
+
203
+ [More Information Needed]
204
+
205
+ ## Model Card Contact
206
+
207
+ [More Information Needed]
208
+ ### Framework versions
209
+
210
+ - PEFT 0.18.1
artifacts/district_llm_adapter_v2/checkpoint-150/adapter_config.json ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "alora_invocation_tokens": null,
3
+ "alpha_pattern": {},
4
+ "arrow_config": null,
5
+ "auto_mapping": {
6
+ "base_model_class": "LlamaForCausalLM",
7
+ "parent_library": "transformers.models.llama.modeling_llama",
8
+ "unsloth_fixed": true
9
+ },
10
+ "base_model_name_or_path": "unsloth/llama-3.1-8b-unsloth-bnb-4bit",
11
+ "bias": "none",
12
+ "corda_config": null,
13
+ "ensure_weight_tying": false,
14
+ "eva_config": null,
15
+ "exclude_modules": null,
16
+ "fan_in_fan_out": false,
17
+ "inference_mode": true,
18
+ "init_lora_weights": true,
19
+ "layer_replication": null,
20
+ "layers_pattern": null,
21
+ "layers_to_transform": null,
22
+ "loftq_config": {},
23
+ "lora_alpha": 16,
24
+ "lora_bias": false,
25
+ "lora_dropout": 0,
26
+ "megatron_config": null,
27
+ "megatron_core": "megatron.core",
28
+ "modules_to_save": null,
29
+ "peft_type": "LORA",
30
+ "peft_version": "0.18.1",
31
+ "qalora_group_size": 16,
32
+ "r": 16,
33
+ "rank_pattern": {},
34
+ "revision": null,
35
+ "target_modules": [
36
+ "down_proj",
37
+ "up_proj",
38
+ "q_proj",
39
+ "k_proj",
40
+ "v_proj",
41
+ "o_proj",
42
+ "gate_proj"
43
+ ],
44
+ "target_parameters": null,
45
+ "task_type": "CAUSAL_LM",
46
+ "trainable_token_indices": null,
47
+ "use_dora": false,
48
+ "use_qalora": false,
49
+ "use_rslora": false
50
+ }
artifacts/district_llm_adapter_v2/checkpoint-150/adapter_model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b43a432bd838d3078559afa204238c64fb87d6d49aa0f53747daa3495f20a201
3
+ size 167832240
artifacts/district_llm_adapter_v2/checkpoint-150/optimizer.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c8b98930b82c827773787056dc5ba8fcecee40c8b3331dd32053627319e71fee
3
+ size 85728229
artifacts/district_llm_adapter_v2/checkpoint-150/rng_state.pth ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:7c800b778fa7e115e4c34de8529902de8b61c9a1b4bab3eb8295d06dafff030e
3
+ size 14645
artifacts/district_llm_adapter_v2/checkpoint-150/scheduler.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0f9a3661913848bed826a840dc7f1ea0f7872a368500bea34bbe970fd6d04f2e
3
+ size 1465
artifacts/district_llm_adapter_v2/checkpoint-150/tokenizer.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6b9e4e7fb171f92fd137b777cc2714bf87d11576700a1dcd7a399e7bbe39537b
3
+ size 17209920
artifacts/district_llm_adapter_v2/checkpoint-150/tokenizer_config.json ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "backend": "tokenizers",
3
+ "bos_token": "<|begin_of_text|>",
4
+ "clean_up_tokenization_spaces": true,
5
+ "eos_token": "<|end_of_text|>",
6
+ "from_slow": true,
7
+ "is_local": false,
8
+ "legacy": false,
9
+ "model_input_names": [
10
+ "input_ids",
11
+ "attention_mask"
12
+ ],
13
+ "model_max_length": 131072,
14
+ "pad_token": "<|finetune_right_pad_id|>",
15
+ "padding_side": "right",
16
+ "tokenizer_class": "TokenizersBackend",
17
+ "unk_token": null
18
+ }
artifacts/district_llm_adapter_v2/checkpoint-150/trainer_state.json ADDED
@@ -0,0 +1,244 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "best_global_step": null,
3
+ "best_metric": null,
4
+ "best_model_checkpoint": null,
5
+ "epoch": 0.8,
6
+ "eval_steps": 50,
7
+ "global_step": 150,
8
+ "is_hyper_param_search": false,
9
+ "is_local_process_zero": true,
10
+ "is_world_process_zero": true,
11
+ "log_history": [
12
+ {
13
+ "epoch": 0.02666666666666667,
14
+ "grad_norm": 0.824774444103241,
15
+ "learning_rate": 4e-05,
16
+ "loss": 1.4378397941589356,
17
+ "step": 5
18
+ },
19
+ {
20
+ "epoch": 0.05333333333333334,
21
+ "grad_norm": 1.7167983055114746,
22
+ "learning_rate": 9e-05,
23
+ "loss": 1.087998867034912,
24
+ "step": 10
25
+ },
26
+ {
27
+ "epoch": 0.08,
28
+ "grad_norm": 0.7535544037818909,
29
+ "learning_rate": 0.00014,
30
+ "loss": 0.5613192558288574,
31
+ "step": 15
32
+ },
33
+ {
34
+ "epoch": 0.10666666666666667,
35
+ "grad_norm": 0.6983357071876526,
36
+ "learning_rate": 0.00019,
37
+ "loss": 0.28872098922729494,
38
+ "step": 20
39
+ },
40
+ {
41
+ "epoch": 0.13333333333333333,
42
+ "grad_norm": 0.8250440955162048,
43
+ "learning_rate": 0.00019989930665413147,
44
+ "loss": 0.22604494094848632,
45
+ "step": 25
46
+ },
47
+ {
48
+ "epoch": 0.16,
49
+ "grad_norm": 0.26267266273498535,
50
+ "learning_rate": 0.00019949058745487522,
51
+ "loss": 0.20742559432983398,
52
+ "step": 30
53
+ },
54
+ {
55
+ "epoch": 0.18666666666666668,
56
+ "grad_norm": 0.27337217330932617,
57
+ "learning_rate": 0.00019876883405951377,
58
+ "loss": 0.1870889902114868,
59
+ "step": 35
60
+ },
61
+ {
62
+ "epoch": 0.21333333333333335,
63
+ "grad_norm": 0.10534920543432236,
64
+ "learning_rate": 0.00019773631737125192,
65
+ "loss": 0.18097405433654784,
66
+ "step": 40
67
+ },
68
+ {
69
+ "epoch": 0.24,
70
+ "grad_norm": 0.13477347791194916,
71
+ "learning_rate": 0.00019639628606958533,
72
+ "loss": 0.17958487272262574,
73
+ "step": 45
74
+ },
75
+ {
76
+ "epoch": 0.26666666666666666,
77
+ "grad_norm": 0.1370360553264618,
78
+ "learning_rate": 0.0001947529563887529,
79
+ "loss": 0.16803257465362548,
80
+ "step": 50
81
+ },
82
+ {
83
+ "epoch": 0.29333333333333333,
84
+ "grad_norm": 0.1513640433549881,
85
+ "learning_rate": 0.0001928114988519039,
86
+ "loss": 0.16801449060440063,
87
+ "step": 55
88
+ },
89
+ {
90
+ "epoch": 0.32,
91
+ "grad_norm": 0.11957086622714996,
92
+ "learning_rate": 0.00019057802200271942,
93
+ "loss": 0.16269906759262084,
94
+ "step": 60
95
+ },
96
+ {
97
+ "epoch": 0.3466666666666667,
98
+ "grad_norm": 0.11077677458524704,
99
+ "learning_rate": 0.0001880595531856738,
100
+ "loss": 0.16706794500350952,
101
+ "step": 65
102
+ },
103
+ {
104
+ "epoch": 0.37333333333333335,
105
+ "grad_norm": 0.10614161193370819,
106
+ "learning_rate": 0.00018526401643540922,
107
+ "loss": 0.16436902284622193,
108
+ "step": 70
109
+ },
110
+ {
111
+ "epoch": 0.4,
112
+ "grad_norm": 0.13366934657096863,
113
+ "learning_rate": 0.00018220020754479102,
114
+ "loss": 0.15710221529006957,
115
+ "step": 75
116
+ },
117
+ {
118
+ "epoch": 0.4266666666666667,
119
+ "grad_norm": 0.1160494014620781,
120
+ "learning_rate": 0.00017887776639008914,
121
+ "loss": 0.16149884462356567,
122
+ "step": 80
123
+ },
124
+ {
125
+ "epoch": 0.4533333333333333,
126
+ "grad_norm": 0.09502895176410675,
127
+ "learning_rate": 0.00017530714660036112,
128
+ "loss": 0.16155229806900023,
129
+ "step": 85
130
+ },
131
+ {
132
+ "epoch": 0.48,
133
+ "grad_norm": 0.11183392256498337,
134
+ "learning_rate": 0.00017149958266646754,
135
+ "loss": 0.15782997608184815,
136
+ "step": 90
137
+ },
138
+ {
139
+ "epoch": 0.5066666666666667,
140
+ "grad_norm": 0.11126931011676788,
141
+ "learning_rate": 0.00016746705459320745,
142
+ "loss": 0.1604154586791992,
143
+ "step": 95
144
+ },
145
+ {
146
+ "epoch": 0.5333333333333333,
147
+ "grad_norm": 0.0941988080739975,
148
+ "learning_rate": 0.00016322225020579099,
149
+ "loss": 0.15799541473388673,
150
+ "step": 100
151
+ },
152
+ {
153
+ "epoch": 0.56,
154
+ "grad_norm": 0.1058623343706131,
155
+ "learning_rate": 0.00015877852522924732,
156
+ "loss": 0.15690511465072632,
157
+ "step": 105
158
+ },
159
+ {
160
+ "epoch": 0.5866666666666667,
161
+ "grad_norm": 0.11555207520723343,
162
+ "learning_rate": 0.00015414986126637258,
163
+ "loss": 0.1615644574165344,
164
+ "step": 110
165
+ },
166
+ {
167
+ "epoch": 0.6133333333333333,
168
+ "grad_norm": 0.2579882740974426,
169
+ "learning_rate": 0.0001493508218064347,
170
+ "loss": 0.16159408092498778,
171
+ "step": 115
172
+ },
173
+ {
174
+ "epoch": 0.64,
175
+ "grad_norm": 0.11453735083341599,
176
+ "learning_rate": 0.00014439650640304822,
177
+ "loss": 0.1569008708000183,
178
+ "step": 120
179
+ },
180
+ {
181
+ "epoch": 0.6666666666666666,
182
+ "grad_norm": 0.12122868746519089,
183
+ "learning_rate": 0.00013930250316539238,
184
+ "loss": 0.15291671752929686,
185
+ "step": 125
186
+ },
187
+ {
188
+ "epoch": 0.6933333333333334,
189
+ "grad_norm": 0.12676002085208893,
190
+ "learning_rate": 0.0001340848397122525,
191
+ "loss": 0.14967869520187377,
192
+ "step": 130
193
+ },
194
+ {
195
+ "epoch": 0.72,
196
+ "grad_norm": 0.14859774708747864,
197
+ "learning_rate": 0.00012875993274320173,
198
+ "loss": 0.1521363615989685,
199
+ "step": 135
200
+ },
201
+ {
202
+ "epoch": 0.7466666666666667,
203
+ "grad_norm": 0.1960573047399521,
204
+ "learning_rate": 0.00012334453638559057,
205
+ "loss": 0.14652782678604126,
206
+ "step": 140
207
+ },
208
+ {
209
+ "epoch": 0.7733333333333333,
210
+ "grad_norm": 0.13388624787330627,
211
+ "learning_rate": 0.00011785568947986367,
212
+ "loss": 0.1499272108078003,
213
+ "step": 145
214
+ },
215
+ {
216
+ "epoch": 0.8,
217
+ "grad_norm": 0.16420726478099823,
218
+ "learning_rate": 0.0001123106619690643,
219
+ "loss": 0.14629043340682985,
220
+ "step": 150
221
+ }
222
+ ],
223
+ "logging_steps": 5,
224
+ "max_steps": 300,
225
+ "num_input_tokens_seen": 0,
226
+ "num_train_epochs": 2,
227
+ "save_steps": 50,
228
+ "stateful_callbacks": {
229
+ "TrainerControl": {
230
+ "args": {
231
+ "should_epoch_stop": false,
232
+ "should_evaluate": false,
233
+ "should_log": false,
234
+ "should_save": true,
235
+ "should_training_stop": false
236
+ },
237
+ "attributes": {}
238
+ }
239
+ },
240
+ "total_flos": 4.921437712999219e+16,
241
+ "train_batch_size": 2,
242
+ "trial_name": null,
243
+ "trial_params": null
244
+ }
artifacts/district_llm_adapter_v2/checkpoint-150/training_args.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:99acc664411451a603c8908d063cb9b0bf85f277436eb270d65909aea5df4002
3
+ size 5777
artifacts/district_llm_adapter_v2/checkpoint-200/README.md ADDED
@@ -0,0 +1,210 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ base_model: unsloth/llama-3.1-8b-unsloth-bnb-4bit
3
+ library_name: peft
4
+ pipeline_tag: text-generation
5
+ tags:
6
+ - base_model:adapter:unsloth/llama-3.1-8b-unsloth-bnb-4bit
7
+ - lora
8
+ - sft
9
+ - transformers
10
+ - trl
11
+ - unsloth
12
+ ---
13
+
14
+ # Model Card for Model ID
15
+
16
+ <!-- Provide a quick summary of what the model is/does. -->
17
+
18
+
19
+
20
+ ## Model Details
21
+
22
+ ### Model Description
23
+
24
+ <!-- Provide a longer summary of what this model is. -->
25
+
26
+
27
+
28
+ - **Developed by:** [More Information Needed]
29
+ - **Funded by [optional]:** [More Information Needed]
30
+ - **Shared by [optional]:** [More Information Needed]
31
+ - **Model type:** [More Information Needed]
32
+ - **Language(s) (NLP):** [More Information Needed]
33
+ - **License:** [More Information Needed]
34
+ - **Finetuned from model [optional]:** [More Information Needed]
35
+
36
+ ### Model Sources [optional]
37
+
38
+ <!-- Provide the basic links for the model. -->
39
+
40
+ - **Repository:** [More Information Needed]
41
+ - **Paper [optional]:** [More Information Needed]
42
+ - **Demo [optional]:** [More Information Needed]
43
+
44
+ ## Uses
45
+
46
+ <!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
47
+
48
+ ### Direct Use
49
+
50
+ <!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
51
+
52
+ [More Information Needed]
53
+
54
+ ### Downstream Use [optional]
55
+
56
+ <!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
57
+
58
+ [More Information Needed]
59
+
60
+ ### Out-of-Scope Use
61
+
62
+ <!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
63
+
64
+ [More Information Needed]
65
+
66
+ ## Bias, Risks, and Limitations
67
+
68
+ <!-- This section is meant to convey both technical and sociotechnical limitations. -->
69
+
70
+ [More Information Needed]
71
+
72
+ ### Recommendations
73
+
74
+ <!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
75
+
76
+ Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
77
+
78
+ ## How to Get Started with the Model
79
+
80
+ Use the code below to get started with the model.
81
+
82
+ [More Information Needed]
83
+
84
+ ## Training Details
85
+
86
+ ### Training Data
87
+
88
+ <!-- This should link to a Dataset Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering. -->
89
+
90
+ [More Information Needed]
91
+
92
+ ### Training Procedure
93
+
94
+ <!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
95
+
96
+ #### Preprocessing [optional]
97
+
98
+ [More Information Needed]
99
+
100
+
101
+ #### Training Hyperparameters
102
+
103
+ - **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
104
+
105
+ #### Speeds, Sizes, Times [optional]
106
+
107
+ <!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
108
+
109
+ [More Information Needed]
110
+
111
+ ## Evaluation
112
+
113
+ <!-- This section describes the evaluation protocols and provides the results. -->
114
+
115
+ ### Testing Data, Factors & Metrics
116
+
117
+ #### Testing Data
118
+
119
+ <!-- This should link to a Dataset Card if possible. -->
120
+
121
+ [More Information Needed]
122
+
123
+ #### Factors
124
+
125
+ <!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
126
+
127
+ [More Information Needed]
128
+
129
+ #### Metrics
130
+
131
+ <!-- These are the evaluation metrics being used, ideally with a description of why. -->
132
+
133
+ [More Information Needed]
134
+
135
+ ### Results
136
+
137
+ [More Information Needed]
138
+
139
+ #### Summary
140
+
141
+
142
+
143
+ ## Model Examination [optional]
144
+
145
+ <!-- Relevant interpretability work for the model goes here -->
146
+
147
+ [More Information Needed]
148
+
149
+ ## Environmental Impact
150
+
151
+ <!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
152
+
153
+ Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
154
+
155
+ - **Hardware Type:** [More Information Needed]
156
+ - **Hours used:** [More Information Needed]
157
+ - **Cloud Provider:** [More Information Needed]
158
+ - **Compute Region:** [More Information Needed]
159
+ - **Carbon Emitted:** [More Information Needed]
160
+
161
+ ## Technical Specifications [optional]
162
+
163
+ ### Model Architecture and Objective
164
+
165
+ [More Information Needed]
166
+
167
+ ### Compute Infrastructure
168
+
169
+ [More Information Needed]
170
+
171
+ #### Hardware
172
+
173
+ [More Information Needed]
174
+
175
+ #### Software
176
+
177
+ [More Information Needed]
178
+
179
+ ## Citation [optional]
180
+
181
+ <!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
182
+
183
+ **BibTeX:**
184
+
185
+ [More Information Needed]
186
+
187
+ **APA:**
188
+
189
+ [More Information Needed]
190
+
191
+ ## Glossary [optional]
192
+
193
+ <!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
194
+
195
+ [More Information Needed]
196
+
197
+ ## More Information [optional]
198
+
199
+ [More Information Needed]
200
+
201
+ ## Model Card Authors [optional]
202
+
203
+ [More Information Needed]
204
+
205
+ ## Model Card Contact
206
+
207
+ [More Information Needed]
208
+ ### Framework versions
209
+
210
+ - PEFT 0.18.1
artifacts/district_llm_adapter_v2/checkpoint-200/adapter_config.json ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "alora_invocation_tokens": null,
3
+ "alpha_pattern": {},
4
+ "arrow_config": null,
5
+ "auto_mapping": {
6
+ "base_model_class": "LlamaForCausalLM",
7
+ "parent_library": "transformers.models.llama.modeling_llama",
8
+ "unsloth_fixed": true
9
+ },
10
+ "base_model_name_or_path": "unsloth/llama-3.1-8b-unsloth-bnb-4bit",
11
+ "bias": "none",
12
+ "corda_config": null,
13
+ "ensure_weight_tying": false,
14
+ "eva_config": null,
15
+ "exclude_modules": null,
16
+ "fan_in_fan_out": false,
17
+ "inference_mode": true,
18
+ "init_lora_weights": true,
19
+ "layer_replication": null,
20
+ "layers_pattern": null,
21
+ "layers_to_transform": null,
22
+ "loftq_config": {},
23
+ "lora_alpha": 16,
24
+ "lora_bias": false,
25
+ "lora_dropout": 0,
26
+ "megatron_config": null,
27
+ "megatron_core": "megatron.core",
28
+ "modules_to_save": null,
29
+ "peft_type": "LORA",
30
+ "peft_version": "0.18.1",
31
+ "qalora_group_size": 16,
32
+ "r": 16,
33
+ "rank_pattern": {},
34
+ "revision": null,
35
+ "target_modules": [
36
+ "down_proj",
37
+ "up_proj",
38
+ "q_proj",
39
+ "k_proj",
40
+ "v_proj",
41
+ "o_proj",
42
+ "gate_proj"
43
+ ],
44
+ "target_parameters": null,
45
+ "task_type": "CAUSAL_LM",
46
+ "trainable_token_indices": null,
47
+ "use_dora": false,
48
+ "use_qalora": false,
49
+ "use_rslora": false
50
+ }
artifacts/district_llm_adapter_v2/checkpoint-200/adapter_model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:fb70b0b07fb3077ba18082208727936bd4e80e731772e0483ce750854c14a75f
3
+ size 167832240
artifacts/district_llm_adapter_v2/checkpoint-200/optimizer.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:b10686233c23619155b5c07584d46c5a14e2afb65b7140a3782c4ee832a667df
3
+ size 85728229
artifacts/district_llm_adapter_v2/checkpoint-200/rng_state.pth ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:181c5f0270cf39930062ddfa3767a2481d0c360f120b11f8e25dbf533a1cdaba
3
+ size 14645
artifacts/district_llm_adapter_v2/checkpoint-200/scheduler.pt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:379326d22f10fb05f8f610d4844919bdb60346c7b0ec96a2613fb34ff5180597
3
+ size 1465
artifacts/district_llm_adapter_v2/checkpoint-200/tokenizer.json ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:6b9e4e7fb171f92fd137b777cc2714bf87d11576700a1dcd7a399e7bbe39537b
3
+ size 17209920
artifacts/district_llm_adapter_v2/checkpoint-200/tokenizer_config.json ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "backend": "tokenizers",
3
+ "bos_token": "<|begin_of_text|>",
4
+ "clean_up_tokenization_spaces": true,
5
+ "eos_token": "<|end_of_text|>",
6
+ "from_slow": true,
7
+ "is_local": false,
8
+ "legacy": false,
9
+ "model_input_names": [
10
+ "input_ids",
11
+ "attention_mask"
12
+ ],
13
+ "model_max_length": 131072,
14
+ "pad_token": "<|finetune_right_pad_id|>",
15
+ "padding_side": "right",
16
+ "tokenizer_class": "TokenizersBackend",
17
+ "unk_token": null
18
+ }
artifacts/district_llm_adapter_v2/checkpoint-200/trainer_state.json ADDED
@@ -0,0 +1,314 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "best_global_step": null,
3
+ "best_metric": null,
4
+ "best_model_checkpoint": null,
5
+ "epoch": 1.064,
6
+ "eval_steps": 50,
7
+ "global_step": 200,
8
+ "is_hyper_param_search": false,
9
+ "is_local_process_zero": true,
10
+ "is_world_process_zero": true,
11
+ "log_history": [
12
+ {
13
+ "epoch": 0.02666666666666667,
14
+ "grad_norm": 0.824774444103241,
15
+ "learning_rate": 4e-05,
16
+ "loss": 1.4378397941589356,
17
+ "step": 5
18
+ },
19
+ {
20
+ "epoch": 0.05333333333333334,
21
+ "grad_norm": 1.7167983055114746,
22
+ "learning_rate": 9e-05,
23
+ "loss": 1.087998867034912,
24
+ "step": 10
25
+ },
26
+ {
27
+ "epoch": 0.08,
28
+ "grad_norm": 0.7535544037818909,
29
+ "learning_rate": 0.00014,
30
+ "loss": 0.5613192558288574,
31
+ "step": 15
32
+ },
33
+ {
34
+ "epoch": 0.10666666666666667,
35
+ "grad_norm": 0.6983357071876526,
36
+ "learning_rate": 0.00019,
37
+ "loss": 0.28872098922729494,
38
+ "step": 20
39
+ },
40
+ {
41
+ "epoch": 0.13333333333333333,
42
+ "grad_norm": 0.8250440955162048,
43
+ "learning_rate": 0.00019989930665413147,
44
+ "loss": 0.22604494094848632,
45
+ "step": 25
46
+ },
47
+ {
48
+ "epoch": 0.16,
49
+ "grad_norm": 0.26267266273498535,
50
+ "learning_rate": 0.00019949058745487522,
51
+ "loss": 0.20742559432983398,
52
+ "step": 30
53
+ },
54
+ {
55
+ "epoch": 0.18666666666666668,
56
+ "grad_norm": 0.27337217330932617,
57
+ "learning_rate": 0.00019876883405951377,
58
+ "loss": 0.1870889902114868,
59
+ "step": 35
60
+ },
61
+ {
62
+ "epoch": 0.21333333333333335,
63
+ "grad_norm": 0.10534920543432236,
64
+ "learning_rate": 0.00019773631737125192,
65
+ "loss": 0.18097405433654784,
66
+ "step": 40
67
+ },
68
+ {
69
+ "epoch": 0.24,
70
+ "grad_norm": 0.13477347791194916,
71
+ "learning_rate": 0.00019639628606958533,
72
+ "loss": 0.17958487272262574,
73
+ "step": 45
74
+ },
75
+ {
76
+ "epoch": 0.26666666666666666,
77
+ "grad_norm": 0.1370360553264618,
78
+ "learning_rate": 0.0001947529563887529,
79
+ "loss": 0.16803257465362548,
80
+ "step": 50
81
+ },
82
+ {
83
+ "epoch": 0.29333333333333333,
84
+ "grad_norm": 0.1513640433549881,
85
+ "learning_rate": 0.0001928114988519039,
86
+ "loss": 0.16801449060440063,
87
+ "step": 55
88
+ },
89
+ {
90
+ "epoch": 0.32,
91
+ "grad_norm": 0.11957086622714996,
92
+ "learning_rate": 0.00019057802200271942,
93
+ "loss": 0.16269906759262084,
94
+ "step": 60
95
+ },
96
+ {
97
+ "epoch": 0.3466666666666667,
98
+ "grad_norm": 0.11077677458524704,
99
+ "learning_rate": 0.0001880595531856738,
100
+ "loss": 0.16706794500350952,
101
+ "step": 65
102
+ },
103
+ {
104
+ "epoch": 0.37333333333333335,
105
+ "grad_norm": 0.10614161193370819,
106
+ "learning_rate": 0.00018526401643540922,
107
+ "loss": 0.16436902284622193,
108
+ "step": 70
109
+ },
110
+ {
111
+ "epoch": 0.4,
112
+ "grad_norm": 0.13366934657096863,
113
+ "learning_rate": 0.00018220020754479102,
114
+ "loss": 0.15710221529006957,
115
+ "step": 75
116
+ },
117
+ {
118
+ "epoch": 0.4266666666666667,
119
+ "grad_norm": 0.1160494014620781,
120
+ "learning_rate": 0.00017887776639008914,
121
+ "loss": 0.16149884462356567,
122
+ "step": 80
123
+ },
124
+ {
125
+ "epoch": 0.4533333333333333,
126
+ "grad_norm": 0.09502895176410675,
127
+ "learning_rate": 0.00017530714660036112,
128
+ "loss": 0.16155229806900023,
129
+ "step": 85
130
+ },
131
+ {
132
+ "epoch": 0.48,
133
+ "grad_norm": 0.11183392256498337,
134
+ "learning_rate": 0.00017149958266646754,
135
+ "loss": 0.15782997608184815,
136
+ "step": 90
137
+ },
138
+ {
139
+ "epoch": 0.5066666666666667,
140
+ "grad_norm": 0.11126931011676788,
141
+ "learning_rate": 0.00016746705459320745,
142
+ "loss": 0.1604154586791992,
143
+ "step": 95
144
+ },
145
+ {
146
+ "epoch": 0.5333333333333333,
147
+ "grad_norm": 0.0941988080739975,
148
+ "learning_rate": 0.00016322225020579099,
149
+ "loss": 0.15799541473388673,
150
+ "step": 100
151
+ },
152
+ {
153
+ "epoch": 0.56,
154
+ "grad_norm": 0.1058623343706131,
155
+ "learning_rate": 0.00015877852522924732,
156
+ "loss": 0.15690511465072632,
157
+ "step": 105
158
+ },
159
+ {
160
+ "epoch": 0.5866666666666667,
161
+ "grad_norm": 0.11555207520723343,
162
+ "learning_rate": 0.00015414986126637258,
163
+ "loss": 0.1615644574165344,
164
+ "step": 110
165
+ },
166
+ {
167
+ "epoch": 0.6133333333333333,
168
+ "grad_norm": 0.2579882740974426,
169
+ "learning_rate": 0.0001493508218064347,
170
+ "loss": 0.16159408092498778,
171
+ "step": 115
172
+ },
173
+ {
174
+ "epoch": 0.64,
175
+ "grad_norm": 0.11453735083341599,
176
+ "learning_rate": 0.00014439650640304822,
177
+ "loss": 0.1569008708000183,
178
+ "step": 120
179
+ },
180
+ {
181
+ "epoch": 0.6666666666666666,
182
+ "grad_norm": 0.12122868746519089,
183
+ "learning_rate": 0.00013930250316539238,
184
+ "loss": 0.15291671752929686,
185
+ "step": 125
186
+ },
187
+ {
188
+ "epoch": 0.6933333333333334,
189
+ "grad_norm": 0.12676002085208893,
190
+ "learning_rate": 0.0001340848397122525,
191
+ "loss": 0.14967869520187377,
192
+ "step": 130
193
+ },
194
+ {
195
+ "epoch": 0.72,
196
+ "grad_norm": 0.14859774708747864,
197
+ "learning_rate": 0.00012875993274320173,
198
+ "loss": 0.1521363615989685,
199
+ "step": 135
200
+ },
201
+ {
202
+ "epoch": 0.7466666666666667,
203
+ "grad_norm": 0.1960573047399521,
204
+ "learning_rate": 0.00012334453638559057,
205
+ "loss": 0.14652782678604126,
206
+ "step": 140
207
+ },
208
+ {
209
+ "epoch": 0.7733333333333333,
210
+ "grad_norm": 0.13388624787330627,
211
+ "learning_rate": 0.00011785568947986367,
212
+ "loss": 0.1499272108078003,
213
+ "step": 145
214
+ },
215
+ {
216
+ "epoch": 0.8,
217
+ "grad_norm": 0.16420726478099823,
218
+ "learning_rate": 0.0001123106619690643,
219
+ "loss": 0.14629043340682985,
220
+ "step": 150
221
+ },
222
+ {
223
+ "epoch": 0.8266666666666667,
224
+ "grad_norm": 0.14654554426670074,
225
+ "learning_rate": 0.00010672690056120399,
226
+ "loss": 0.14661697149276734,
227
+ "step": 155
228
+ },
229
+ {
230
+ "epoch": 0.8533333333333334,
231
+ "grad_norm": 0.14784203469753265,
232
+ "learning_rate": 0.0001011219738354646,
233
+ "loss": 0.13817673921585083,
234
+ "step": 160
235
+ },
236
+ {
237
+ "epoch": 0.88,
238
+ "grad_norm": 0.13851715624332428,
239
+ "learning_rate": 9.551351696494854e-05,
240
+ "loss": 0.14781265258789061,
241
+ "step": 165
242
+ },
243
+ {
244
+ "epoch": 0.9066666666666666,
245
+ "grad_norm": 0.17259690165519714,
246
+ "learning_rate": 8.991917622989956e-05,
247
+ "loss": 0.14397273063659669,
248
+ "step": 170
249
+ },
250
+ {
251
+ "epoch": 0.9333333333333333,
252
+ "grad_norm": 0.287122517824173,
253
+ "learning_rate": 8.435655349597689e-05,
254
+ "loss": 0.14055378437042237,
255
+ "step": 175
256
+ },
257
+ {
258
+ "epoch": 0.96,
259
+ "grad_norm": 0.15599672496318817,
260
+ "learning_rate": 7.884315083227373e-05,
261
+ "loss": 0.14050980806350707,
262
+ "step": 180
263
+ },
264
+ {
265
+ "epoch": 0.9866666666666667,
266
+ "grad_norm": 0.17161861062049866,
267
+ "learning_rate": 7.339631544333249e-05,
268
+ "loss": 0.13583474159240722,
269
+ "step": 185
270
+ },
271
+ {
272
+ "epoch": 1.0106666666666666,
273
+ "grad_norm": 0.17195405066013336,
274
+ "learning_rate": 6.803318508842187e-05,
275
+ "loss": 0.14056421518325807,
276
+ "step": 190
277
+ },
278
+ {
279
+ "epoch": 1.0373333333333334,
280
+ "grad_norm": 0.14843153953552246,
281
+ "learning_rate": 6.277063415980549e-05,
282
+ "loss": 0.14321362972259521,
283
+ "step": 195
284
+ },
285
+ {
286
+ "epoch": 1.064,
287
+ "grad_norm": 0.17835235595703125,
288
+ "learning_rate": 5.762522058966113e-05,
289
+ "loss": 0.13067924976348877,
290
+ "step": 200
291
+ }
292
+ ],
293
+ "logging_steps": 5,
294
+ "max_steps": 300,
295
+ "num_input_tokens_seen": 0,
296
+ "num_train_epochs": 2,
297
+ "save_steps": 50,
298
+ "stateful_callbacks": {
299
+ "TrainerControl": {
300
+ "args": {
301
+ "should_epoch_stop": false,
302
+ "should_evaluate": false,
303
+ "should_log": false,
304
+ "should_save": true,
305
+ "should_training_stop": false
306
+ },
307
+ "attributes": {}
308
+ }
309
+ },
310
+ "total_flos": 6.496001098695475e+16,
311
+ "train_batch_size": 2,
312
+ "trial_name": null,
313
+ "trial_params": null
314
+ }
artifacts/district_llm_adapter_v2/checkpoint-200/training_args.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:99acc664411451a603c8908d063cb9b0bf85f277436eb270d65909aea5df4002
3
+ size 5777
artifacts/district_llm_adapter_v2/checkpoint-250/README.md ADDED
@@ -0,0 +1,210 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ base_model: unsloth/llama-3.1-8b-unsloth-bnb-4bit
3
+ library_name: peft
4
+ pipeline_tag: text-generation
5
+ tags:
6
+ - base_model:adapter:unsloth/llama-3.1-8b-unsloth-bnb-4bit
7
+ - lora
8
+ - sft
9
+ - transformers
10
+ - trl
11
+ - unsloth
12
+ ---
13
+
14
+ # Model Card for Model ID
15
+
16
+ <!-- Provide a quick summary of what the model is/does. -->
17
+
18
+
19
+
20
+ ## Model Details
21
+
22
+ ### Model Description
23
+
24
+ <!-- Provide a longer summary of what this model is. -->
25
+
26
+
27
+
28
+ - **Developed by:** [More Information Needed]
29
+ - **Funded by [optional]:** [More Information Needed]
30
+ - **Shared by [optional]:** [More Information Needed]
31
+ - **Model type:** [More Information Needed]
32
+ - **Language(s) (NLP):** [More Information Needed]
33
+ - **License:** [More Information Needed]
34
+ - **Finetuned from model [optional]:** [More Information Needed]
35
+
36
+ ### Model Sources [optional]
37
+
38
+ <!-- Provide the basic links for the model. -->
39
+
40
+ - **Repository:** [More Information Needed]
41
+ - **Paper [optional]:** [More Information Needed]
42
+ - **Demo [optional]:** [More Information Needed]
43
+
44
+ ## Uses
45
+
46
+ <!-- Address questions around how the model is intended to be used, including the foreseeable users of the model and those affected by the model. -->
47
+
48
+ ### Direct Use
49
+
50
+ <!-- This section is for the model use without fine-tuning or plugging into a larger ecosystem/app. -->
51
+
52
+ [More Information Needed]
53
+
54
+ ### Downstream Use [optional]
55
+
56
+ <!-- This section is for the model use when fine-tuned for a task, or when plugged into a larger ecosystem/app -->
57
+
58
+ [More Information Needed]
59
+
60
+ ### Out-of-Scope Use
61
+
62
+ <!-- This section addresses misuse, malicious use, and uses that the model will not work well for. -->
63
+
64
+ [More Information Needed]
65
+
66
+ ## Bias, Risks, and Limitations
67
+
68
+ <!-- This section is meant to convey both technical and sociotechnical limitations. -->
69
+
70
+ [More Information Needed]
71
+
72
+ ### Recommendations
73
+
74
+ <!-- This section is meant to convey recommendations with respect to the bias, risk, and technical limitations. -->
75
+
76
+ Users (both direct and downstream) should be made aware of the risks, biases and limitations of the model. More information needed for further recommendations.
77
+
78
+ ## How to Get Started with the Model
79
+
80
+ Use the code below to get started with the model.
81
+
82
+ [More Information Needed]
83
+
84
+ ## Training Details
85
+
86
+ ### Training Data
87
+
88
+ <!-- This should link to a Dataset Card, perhaps with a short stub of information on what the training data is all about as well as documentation related to data pre-processing or additional filtering. -->
89
+
90
+ [More Information Needed]
91
+
92
+ ### Training Procedure
93
+
94
+ <!-- This relates heavily to the Technical Specifications. Content here should link to that section when it is relevant to the training procedure. -->
95
+
96
+ #### Preprocessing [optional]
97
+
98
+ [More Information Needed]
99
+
100
+
101
+ #### Training Hyperparameters
102
+
103
+ - **Training regime:** [More Information Needed] <!--fp32, fp16 mixed precision, bf16 mixed precision, bf16 non-mixed precision, fp16 non-mixed precision, fp8 mixed precision -->
104
+
105
+ #### Speeds, Sizes, Times [optional]
106
+
107
+ <!-- This section provides information about throughput, start/end time, checkpoint size if relevant, etc. -->
108
+
109
+ [More Information Needed]
110
+
111
+ ## Evaluation
112
+
113
+ <!-- This section describes the evaluation protocols and provides the results. -->
114
+
115
+ ### Testing Data, Factors & Metrics
116
+
117
+ #### Testing Data
118
+
119
+ <!-- This should link to a Dataset Card if possible. -->
120
+
121
+ [More Information Needed]
122
+
123
+ #### Factors
124
+
125
+ <!-- These are the things the evaluation is disaggregating by, e.g., subpopulations or domains. -->
126
+
127
+ [More Information Needed]
128
+
129
+ #### Metrics
130
+
131
+ <!-- These are the evaluation metrics being used, ideally with a description of why. -->
132
+
133
+ [More Information Needed]
134
+
135
+ ### Results
136
+
137
+ [More Information Needed]
138
+
139
+ #### Summary
140
+
141
+
142
+
143
+ ## Model Examination [optional]
144
+
145
+ <!-- Relevant interpretability work for the model goes here -->
146
+
147
+ [More Information Needed]
148
+
149
+ ## Environmental Impact
150
+
151
+ <!-- Total emissions (in grams of CO2eq) and additional considerations, such as electricity usage, go here. Edit the suggested text below accordingly -->
152
+
153
+ Carbon emissions can be estimated using the [Machine Learning Impact calculator](https://mlco2.github.io/impact#compute) presented in [Lacoste et al. (2019)](https://arxiv.org/abs/1910.09700).
154
+
155
+ - **Hardware Type:** [More Information Needed]
156
+ - **Hours used:** [More Information Needed]
157
+ - **Cloud Provider:** [More Information Needed]
158
+ - **Compute Region:** [More Information Needed]
159
+ - **Carbon Emitted:** [More Information Needed]
160
+
161
+ ## Technical Specifications [optional]
162
+
163
+ ### Model Architecture and Objective
164
+
165
+ [More Information Needed]
166
+
167
+ ### Compute Infrastructure
168
+
169
+ [More Information Needed]
170
+
171
+ #### Hardware
172
+
173
+ [More Information Needed]
174
+
175
+ #### Software
176
+
177
+ [More Information Needed]
178
+
179
+ ## Citation [optional]
180
+
181
+ <!-- If there is a paper or blog post introducing the model, the APA and Bibtex information for that should go in this section. -->
182
+
183
+ **BibTeX:**
184
+
185
+ [More Information Needed]
186
+
187
+ **APA:**
188
+
189
+ [More Information Needed]
190
+
191
+ ## Glossary [optional]
192
+
193
+ <!-- If relevant, include terms and calculations in this section that can help readers understand the model or model card. -->
194
+
195
+ [More Information Needed]
196
+
197
+ ## More Information [optional]
198
+
199
+ [More Information Needed]
200
+
201
+ ## Model Card Authors [optional]
202
+
203
+ [More Information Needed]
204
+
205
+ ## Model Card Contact
206
+
207
+ [More Information Needed]
208
+ ### Framework versions
209
+
210
+ - PEFT 0.18.1
artifacts/district_llm_adapter_v2/checkpoint-250/adapter_config.json ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "alora_invocation_tokens": null,
3
+ "alpha_pattern": {},
4
+ "arrow_config": null,
5
+ "auto_mapping": {
6
+ "base_model_class": "LlamaForCausalLM",
7
+ "parent_library": "transformers.models.llama.modeling_llama",
8
+ "unsloth_fixed": true
9
+ },
10
+ "base_model_name_or_path": "unsloth/llama-3.1-8b-unsloth-bnb-4bit",
11
+ "bias": "none",
12
+ "corda_config": null,
13
+ "ensure_weight_tying": false,
14
+ "eva_config": null,
15
+ "exclude_modules": null,
16
+ "fan_in_fan_out": false,
17
+ "inference_mode": true,
18
+ "init_lora_weights": true,
19
+ "layer_replication": null,
20
+ "layers_pattern": null,
21
+ "layers_to_transform": null,
22
+ "loftq_config": {},
23
+ "lora_alpha": 16,
24
+ "lora_bias": false,
25
+ "lora_dropout": 0,
26
+ "megatron_config": null,
27
+ "megatron_core": "megatron.core",
28
+ "modules_to_save": null,
29
+ "peft_type": "LORA",
30
+ "peft_version": "0.18.1",
31
+ "qalora_group_size": 16,
32
+ "r": 16,
33
+ "rank_pattern": {},
34
+ "revision": null,
35
+ "target_modules": [
36
+ "down_proj",
37
+ "up_proj",
38
+ "q_proj",
39
+ "k_proj",
40
+ "v_proj",
41
+ "o_proj",
42
+ "gate_proj"
43
+ ],
44
+ "target_parameters": null,
45
+ "task_type": "CAUSAL_LM",
46
+ "trainable_token_indices": null,
47
+ "use_dora": false,
48
+ "use_qalora": false,
49
+ "use_rslora": false
50
+ }