Spaces:
Sleeping
Consolidate vision finetune files under finetune/vision/
Browse filesMove all vision-specific finetune assets into finetune/vision/ so the
vision fine-tuning work lives in one place, separate from the text-gen
work: the synthetic generator, dataset builders, schema/contract/prompts,
configs/, patches/, fixtures/, the model + dataset cards, the vision
reports, and the repo-root vision runlog all relocate. Update every
importer (modal/, evals/, tests/, intra-package) to finetune.vision.* and
the moved path strings (configs, patches, fixtures, cards, reports) in the
Modal scripts and Makefile.
Kept at finetune/ root: the text-gen files (minicpm5/qa/whatsapp) and
redact.py, which is shared — the text distill pipeline copies it too, so
it is not vision-specific. modal/ and evals/ stay top-level shared infra.
make check green: 626 passed, 1 skipped; ruff + format clean.
- Makefile +2 -2
- evals/stage1_adapter.py +1 -1
- evals/stage2_adapter.py +1 -1
- evals/stage2_scoring.py +1 -1
- finetune/vision/__init__.py +0 -0
- finetune/{audit_transcriptions.py → vision/audit_transcriptions.py} +0 -0
- finetune/{build_auxiliary_dataset.py → vision/build_auxiliary_dataset.py} +2 -2
- finetune/{build_mixed_dataset.py → vision/build_mixed_dataset.py} +2 -2
- finetune/{build_real_corpus.py → vision/build_real_corpus.py} +2 -2
- finetune/{build_stage1_dataset.py → vision/build_stage1_dataset.py} +1 -1
- finetune/{build_v3_dataset.py → vision/build_v3_dataset.py} +3 -3
- finetune/{catalog.py → vision/catalog.py} +0 -0
- finetune/{configs → vision/configs}/minicpmv4_6_lora_export.yaml +0 -0
- finetune/{configs → vision/configs}/minicpmv4_6_lora_export_v2.yaml +0 -0
- finetune/{configs → vision/configs}/minicpmv4_6_lora_export_v3.yaml +0 -0
- finetune/{configs → vision/configs}/minicpmv4_6_lora_export_v4.yaml +0 -0
- finetune/{configs → vision/configs}/minicpmv4_6_lora_sft.yaml +0 -0
- finetune/{configs → vision/configs}/minicpmv4_6_lora_sft_v2.yaml +0 -0
- finetune/{configs → vision/configs}/minicpmv4_6_lora_sft_v3.yaml +0 -0
- finetune/{configs → vision/configs}/minicpmv4_6_lora_sft_v4.yaml +0 -0
- finetune/{configs → vision/configs}/minicpmv4_6_lora_sft_v5.yaml +0 -0
- finetune/{convert_v1_to_v2.py → vision/convert_v1_to_v2.py} +2 -2
- finetune/{dataset_card_synthetic_ptbr.md → vision/dataset_card_synthetic_ptbr.md} +0 -0
- finetune/{fix_v2_coercion.py → vision/fix_v2_coercion.py} +2 -2
- finetune/{fixtures → vision/fixtures}/fixture_train.json +0 -0
- finetune/{fixtures → vision/fixtures}/images/chat.jpg +0 -0
- finetune/{fixtures → vision/fixtures}/images/receipt.jpg +0 -0
- finetune/{fixtures → vision/fixtures}/images/ticket.jpg +0 -0
- finetune/{fixtures → vision/fixtures}/labels.jsonl +0 -0
- finetune/{merge_export.py → vision/merge_export.py} +2 -2
- finetune/{merge_labels.py → vision/merge_labels.py} +0 -0
- finetune/{minicpm_processor.py → vision/minicpm_processor.py} +0 -0
- finetune/{model_card_v1.md → vision/model_card_v1.md} +0 -0
- finetune/{package_modal_dataset.py → vision/package_modal_dataset.py} +1 -1
- finetune/{patches → vision/patches}/apply_llamafactory_loader_patch.py +0 -0
- finetune/{prompts.py → vision/prompts.py} +0 -0
- finetune/{reports → vision/reports}/minicpmv4_6_vision_v3_runlog.md +0 -0
- finetune/{reports → vision/reports}/transcription_coverage.json +0 -0
- run_log_minicpm_vision_fine_tune.md → finetune/vision/run_log_minicpm_vision_fine_tune.md +0 -0
- finetune/{stage2_contract.py → vision/stage2_contract.py} +1 -1
- finetune/{synthetic_example_export.py → vision/synthetic_example_export.py} +1 -1
- finetune/{synthetic_vision_dataset.py → vision/synthetic_vision_dataset.py} +2 -2
- finetune/{train.py → vision/train.py} +7 -7
- finetune/{train_schema.py → vision/train_schema.py} +0 -0
- finetune/{v2_schema.py → vision/v2_schema.py} +0 -0
- finetune/{validate_coverage.py → vision/validate_coverage.py} +0 -0
- finetune/{validate_v2_labels.py → vision/validate_v2_labels.py} +1 -1
- modal/judge_pipeline.py +1 -1
- modal/merge_export.py +6 -11
- modal/publish_dataset.py +1 -1
|
@@ -27,9 +27,9 @@ modal-profile:
|
|
| 27 |
modal profile activate $(MODAL_PROFILE)
|
| 28 |
|
| 29 |
modal-train-v2:
|
| 30 |
-
MODAL_PROFILE=$(MODAL_PROFILE) uv run python finetune/train.py --modal --detach \
|
| 31 |
--train-json finetune/labeled/v2/all_train.json \
|
| 32 |
-
--config finetune/configs/minicpmv4_6_lora_sft_v2.yaml \
|
| 33 |
--hf-repo marinarosa/vivamais-vision-lora-v2
|
| 34 |
|
| 35 |
modal-merge-v2:
|
|
|
|
| 27 |
modal profile activate $(MODAL_PROFILE)
|
| 28 |
|
| 29 |
modal-train-v2:
|
| 30 |
+
MODAL_PROFILE=$(MODAL_PROFILE) uv run python finetune/vision/train.py --modal --detach \
|
| 31 |
--train-json finetune/labeled/v2/all_train.json \
|
| 32 |
+
--config finetune/vision/configs/minicpmv4_6_lora_sft_v2.yaml \
|
| 33 |
--hf-repo marinarosa/vivamais-vision-lora-v2
|
| 34 |
|
| 35 |
modal-merge-v2:
|
|
@@ -6,7 +6,7 @@ import json
|
|
| 6 |
import re
|
| 7 |
from pathlib import Path
|
| 8 |
|
| 9 |
-
from finetune.prompts import STAGE1_PROMPT
|
| 10 |
|
| 11 |
DEFAULT_BASE_MODEL = "openbmb/MiniCPM-V-4.6"
|
| 12 |
DEFAULT_TUNED_MODEL = "marinarosa/vivamais-vision-merged-v2"
|
|
|
|
| 6 |
import re
|
| 7 |
from pathlib import Path
|
| 8 |
|
| 9 |
+
from finetune.vision.prompts import STAGE1_PROMPT
|
| 10 |
|
| 11 |
DEFAULT_BASE_MODEL = "openbmb/MiniCPM-V-4.6"
|
| 12 |
DEFAULT_TUNED_MODEL = "marinarosa/vivamais-vision-merged-v2"
|
|
@@ -6,7 +6,7 @@ import json
|
|
| 6 |
import re
|
| 7 |
from pathlib import Path
|
| 8 |
|
| 9 |
-
from finetune.prompts import stage2_vision_prompt
|
| 10 |
from vivamais.domain.artifacts import ArtifactKind
|
| 11 |
|
| 12 |
DEFAULT_BASE_MODEL = "openbmb/MiniCPM-V-4.6"
|
|
|
|
| 6 |
import re
|
| 7 |
from pathlib import Path
|
| 8 |
|
| 9 |
+
from finetune.vision.prompts import stage2_vision_prompt
|
| 10 |
from vivamais.domain.artifacts import ArtifactKind
|
| 11 |
|
| 12 |
DEFAULT_BASE_MODEL = "openbmb/MiniCPM-V-4.6"
|
|
@@ -7,7 +7,7 @@ from collections import defaultdict
|
|
| 7 |
from typing import Any
|
| 8 |
|
| 9 |
from evals.metrics import normalize_text
|
| 10 |
-
from finetune.v2_schema import STAGE2_FIELDS
|
| 11 |
from vivamais.adapters.models.dspy_payloads import (
|
| 12 |
EXTRACTION_PROGRAMS,
|
| 13 |
LineItemFields,
|
|
|
|
| 7 |
from typing import Any
|
| 8 |
|
| 9 |
from evals.metrics import normalize_text
|
| 10 |
+
from finetune.vision.v2_schema import STAGE2_FIELDS
|
| 11 |
from vivamais.adapters.models.dspy_payloads import (
|
| 12 |
EXTRACTION_PROGRAMS,
|
| 13 |
LineItemFields,
|
|
File without changes
|
|
File without changes
|
|
@@ -12,9 +12,9 @@ _ROOT = Path(__file__).resolve().parents[1]
|
|
| 12 |
if str(_ROOT) not in sys.path:
|
| 13 |
sys.path.insert(0, str(_ROOT))
|
| 14 |
|
| 15 |
-
from finetune.prompts import stage2_assistant, stage2_vision_prompt
|
| 16 |
from finetune.redact import redact_v2_row
|
| 17 |
-
from finetune.v2_schema import EXTRACTABLE_KINDS
|
| 18 |
from vivamais.domain.artifacts import ArtifactKind
|
| 19 |
|
| 20 |
|
|
|
|
| 12 |
if str(_ROOT) not in sys.path:
|
| 13 |
sys.path.insert(0, str(_ROOT))
|
| 14 |
|
| 15 |
+
from finetune.vision.prompts import stage2_assistant, stage2_vision_prompt
|
| 16 |
from finetune.redact import redact_v2_row
|
| 17 |
+
from finetune.vision.v2_schema import EXTRACTABLE_KINDS
|
| 18 |
from vivamais.domain.artifacts import ArtifactKind
|
| 19 |
|
| 20 |
|
|
@@ -13,8 +13,8 @@ _ROOT = Path(__file__).resolve().parents[1]
|
|
| 13 |
if str(_ROOT) not in sys.path:
|
| 14 |
sys.path.insert(0, str(_ROOT))
|
| 15 |
|
| 16 |
-
from finetune.build_auxiliary_dataset import to_training_row as auxiliary_row
|
| 17 |
-
from finetune.build_stage1_dataset import to_training_row as stage1_row
|
| 18 |
|
| 19 |
|
| 20 |
def load_labels(path: Path) -> list[dict[str, Any]]:
|
|
|
|
| 13 |
if str(_ROOT) not in sys.path:
|
| 14 |
sys.path.insert(0, str(_ROOT))
|
| 15 |
|
| 16 |
+
from finetune.vision.build_auxiliary_dataset import to_training_row as auxiliary_row
|
| 17 |
+
from finetune.vision.build_stage1_dataset import to_training_row as stage1_row
|
| 18 |
|
| 19 |
|
| 20 |
def load_labels(path: Path) -> list[dict[str, Any]]:
|
|
@@ -34,8 +34,8 @@ if str(_ROOT / "src") not in sys.path:
|
|
| 34 |
if str(_ROOT) not in sys.path:
|
| 35 |
sys.path.insert(0, str(_ROOT))
|
| 36 |
|
| 37 |
-
from finetune.catalog import extract_all
|
| 38 |
-
from finetune.synthetic_vision_dataset import normalize_text
|
| 39 |
|
| 40 |
SOURCE_SUFFIXES = (".jpg", ".jpeg", ".png", ".pdf")
|
| 41 |
IGNORED_SUFFIXES = (".webp",)
|
|
|
|
| 34 |
if str(_ROOT) not in sys.path:
|
| 35 |
sys.path.insert(0, str(_ROOT))
|
| 36 |
|
| 37 |
+
from finetune.vision.catalog import extract_all
|
| 38 |
+
from finetune.vision.synthetic_vision_dataset import normalize_text
|
| 39 |
|
| 40 |
SOURCE_SUFFIXES = (".jpg", ".jpeg", ".png", ".pdf")
|
| 41 |
IGNORED_SUFFIXES = (".webp",)
|
|
@@ -12,7 +12,7 @@ _ROOT = Path(__file__).resolve().parents[1]
|
|
| 12 |
if str(_ROOT) not in sys.path:
|
| 13 |
sys.path.insert(0, str(_ROOT))
|
| 14 |
|
| 15 |
-
from finetune.prompts import STAGE1_PROMPT, stage1_assistant
|
| 16 |
from finetune.redact import redact_v2_row
|
| 17 |
|
| 18 |
|
|
|
|
| 12 |
if str(_ROOT) not in sys.path:
|
| 13 |
sys.path.insert(0, str(_ROOT))
|
| 14 |
|
| 15 |
+
from finetune.vision.prompts import STAGE1_PROMPT, stage1_assistant
|
| 16 |
from finetune.redact import redact_v2_row
|
| 17 |
|
| 18 |
|
|
@@ -5,7 +5,7 @@ labels (teacher_labels.jsonl), after carving a stratified real eval holdout that
|
|
| 5 |
is NEVER in train. Emits one shuffled all_train.json that package_modal_dataset
|
| 6 |
turns into the Modal/LLaMA-Factory package.
|
| 7 |
|
| 8 |
-
python -m finetune.build_v3_dataset \
|
| 9 |
--teacher finetune/labeled/v2/teacher_labels.jsonl \
|
| 10 |
--synthetic finetune/workspace/synthetic_vision \
|
| 11 |
--workspace finetune/workspace \
|
|
@@ -29,8 +29,8 @@ if str(_ROOT / "src") not in sys.path:
|
|
| 29 |
if str(_ROOT) not in sys.path:
|
| 30 |
sys.path.insert(0, str(_ROOT))
|
| 31 |
|
| 32 |
-
from finetune.build_auxiliary_dataset import to_training_row as stage2_row
|
| 33 |
-
from finetune.build_stage1_dataset import to_training_row as stage1_row
|
| 34 |
|
| 35 |
DEFAULT_EVAL_FRACTION = 0.15
|
| 36 |
DEFAULT_SEED = 42
|
|
|
|
| 5 |
is NEVER in train. Emits one shuffled all_train.json that package_modal_dataset
|
| 6 |
turns into the Modal/LLaMA-Factory package.
|
| 7 |
|
| 8 |
+
python -m finetune.vision.build_v3_dataset \
|
| 9 |
--teacher finetune/labeled/v2/teacher_labels.jsonl \
|
| 10 |
--synthetic finetune/workspace/synthetic_vision \
|
| 11 |
--workspace finetune/workspace \
|
|
|
|
| 29 |
if str(_ROOT) not in sys.path:
|
| 30 |
sys.path.insert(0, str(_ROOT))
|
| 31 |
|
| 32 |
+
from finetune.vision.build_auxiliary_dataset import to_training_row as stage2_row
|
| 33 |
+
from finetune.vision.build_stage1_dataset import to_training_row as stage1_row
|
| 34 |
|
| 35 |
DEFAULT_EVAL_FRACTION = 0.15
|
| 36 |
DEFAULT_SEED = 42
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -13,8 +13,8 @@ _ROOT = Path(__file__).resolve().parents[1]
|
|
| 13 |
if str(_ROOT) not in sys.path:
|
| 14 |
sys.path.insert(0, str(_ROOT))
|
| 15 |
|
| 16 |
-
from finetune.audit_transcriptions import transcription_path
|
| 17 |
-
from finetune.v2_schema import STAGE2_FIELDS, validate_v2_row
|
| 18 |
from vivamais.domain.artifacts import ArtifactKind
|
| 19 |
|
| 20 |
_BOARDING_CUES = (
|
|
|
|
| 13 |
if str(_ROOT) not in sys.path:
|
| 14 |
sys.path.insert(0, str(_ROOT))
|
| 15 |
|
| 16 |
+
from finetune.vision.audit_transcriptions import transcription_path
|
| 17 |
+
from finetune.vision.v2_schema import STAGE2_FIELDS, validate_v2_row
|
| 18 |
from vivamais.domain.artifacts import ArtifactKind
|
| 19 |
|
| 20 |
_BOARDING_CUES = (
|
|
File without changes
|
|
@@ -14,8 +14,8 @@ if str(_ROOT) not in sys.path:
|
|
| 14 |
sys.path.insert(0, str(_ROOT))
|
| 15 |
sys.path.insert(0, str(_ROOT / "src"))
|
| 16 |
|
| 17 |
-
from finetune.validate_v2_labels import _coerce_row, validate_v2_row
|
| 18 |
-
from finetune.v2_schema import STAGE2_FIELDS, validate_v2_row as _validate
|
| 19 |
from vivamais.domain.artifacts import ArtifactKind
|
| 20 |
|
| 21 |
|
|
|
|
| 14 |
sys.path.insert(0, str(_ROOT))
|
| 15 |
sys.path.insert(0, str(_ROOT / "src"))
|
| 16 |
|
| 17 |
+
from finetune.vision.validate_v2_labels import _coerce_row, validate_v2_row
|
| 18 |
+
from finetune.vision.v2_schema import STAGE2_FIELDS, validate_v2_row as _validate
|
| 19 |
from vivamais.domain.artifacts import ArtifactKind
|
| 20 |
|
| 21 |
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -13,9 +13,9 @@ _ROOT = Path(__file__).resolve().parents[1]
|
|
| 13 |
if str(_ROOT) not in sys.path:
|
| 14 |
sys.path.insert(0, str(_ROOT))
|
| 15 |
|
| 16 |
-
from finetune.train_schema import TrainValidationError, validate_export_config
|
| 17 |
|
| 18 |
-
DEFAULT_EXPORT_CONFIG = Path("finetune/configs/minicpmv4_6_lora_export.yaml")
|
| 19 |
HF_VISION_REPO = "marinarosa/vivamais-vision"
|
| 20 |
HF_LORA_REPO = "marinarosa/vivamais-vision-lora"
|
| 21 |
HF_MERGED_REPO = "marinarosa/vivamais-vision-merged"
|
|
|
|
| 13 |
if str(_ROOT) not in sys.path:
|
| 14 |
sys.path.insert(0, str(_ROOT))
|
| 15 |
|
| 16 |
+
from finetune.vision.train_schema import TrainValidationError, validate_export_config
|
| 17 |
|
| 18 |
+
DEFAULT_EXPORT_CONFIG = Path("finetune/vision/configs/minicpmv4_6_lora_export.yaml")
|
| 19 |
HF_VISION_REPO = "marinarosa/vivamais-vision"
|
| 20 |
HF_LORA_REPO = "marinarosa/vivamais-vision-lora"
|
| 21 |
HF_MERGED_REPO = "marinarosa/vivamais-vision-merged"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -14,7 +14,7 @@ _ROOT = Path(__file__).resolve().parents[1]
|
|
| 14 |
if str(_ROOT) not in sys.path:
|
| 15 |
sys.path.insert(0, str(_ROOT))
|
| 16 |
|
| 17 |
-
from finetune.train_schema import TrainValidationError, validate_training_rows
|
| 18 |
|
| 19 |
CONVERT_TO_JPEG_SUFFIXES = frozenset({".webp", ".gif", ".bmp", ".tiff", ".tif"})
|
| 20 |
# PDFs (real e-tickets) are rendered to JPEG from their first page.
|
|
|
|
| 14 |
if str(_ROOT) not in sys.path:
|
| 15 |
sys.path.insert(0, str(_ROOT))
|
| 16 |
|
| 17 |
+
from finetune.vision.train_schema import TrainValidationError, validate_training_rows
|
| 18 |
|
| 19 |
CONVERT_TO_JPEG_SUFFIXES = frozenset({".webp", ".gif", ".bmp", ".tiff", ".tif"})
|
| 20 |
# PDFs (real e-tickets) are rendered to JPEG from their first page.
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -11,7 +11,7 @@ from __future__ import annotations
|
|
| 11 |
|
| 12 |
from typing import Any
|
| 13 |
|
| 14 |
-
from finetune.v2_schema import EXTRACTABLE_KINDS, STAGE2_FIELDS
|
| 15 |
from vivamais.domain.artifacts import ArtifactKind
|
| 16 |
|
| 17 |
# Fields whose v2 value is a list (everything else is a scalar string).
|
|
|
|
| 11 |
|
| 12 |
from typing import Any
|
| 13 |
|
| 14 |
+
from finetune.vision.v2_schema import EXTRACTABLE_KINDS, STAGE2_FIELDS
|
| 15 |
from vivamais.domain.artifacts import ArtifactKind
|
| 16 |
|
| 17 |
# Fields whose v2 value is a list (everything else is a scalar string).
|
|
@@ -21,7 +21,7 @@ if str(_ROOT / "src") not in sys.path:
|
|
| 21 |
if str(_ROOT) not in sys.path:
|
| 22 |
sys.path.insert(0, str(_ROOT))
|
| 23 |
|
| 24 |
-
from finetune.synthetic_vision_dataset import (
|
| 25 |
Fonts,
|
| 26 |
RENDERERS,
|
| 27 |
finish_image,
|
|
|
|
| 21 |
if str(_ROOT) not in sys.path:
|
| 22 |
sys.path.insert(0, str(_ROOT))
|
| 23 |
|
| 24 |
+
from finetune.vision.synthetic_vision_dataset import (
|
| 25 |
Fonts,
|
| 26 |
RENDERERS,
|
| 27 |
finish_image,
|
|
@@ -35,8 +35,8 @@ if str(_ROOT / "src") not in sys.path:
|
|
| 35 |
if str(_ROOT) not in sys.path:
|
| 36 |
sys.path.insert(0, str(_ROOT))
|
| 37 |
|
| 38 |
-
from finetune.prompts import STAGE1_PROMPT, stage1_assistant, stage2_assistant, stage2_vision_prompt
|
| 39 |
-
from finetune.v2_schema import validate_v2_row
|
| 40 |
from vivamais.domain.artifacts import ArtifactKind
|
| 41 |
|
| 42 |
REFERENCE_SUFFIXES = {".jpg", ".jpeg", ".pdf"}
|
|
|
|
| 35 |
if str(_ROOT) not in sys.path:
|
| 36 |
sys.path.insert(0, str(_ROOT))
|
| 37 |
|
| 38 |
+
from finetune.vision.prompts import STAGE1_PROMPT, stage1_assistant, stage2_assistant, stage2_vision_prompt
|
| 39 |
+
from finetune.vision.v2_schema import validate_v2_row
|
| 40 |
from vivamais.domain.artifacts import ArtifactKind
|
| 41 |
|
| 42 |
REFERENCE_SUFFIXES = {".jpg", ".jpeg", ".pdf"}
|
|
@@ -14,9 +14,9 @@ _ROOT = Path(__file__).resolve().parents[1]
|
|
| 14 |
if str(_ROOT) not in sys.path:
|
| 15 |
sys.path.insert(0, str(_ROOT))
|
| 16 |
|
| 17 |
-
from finetune.build_mixed_dataset import build_mixed
|
| 18 |
-
from finetune.package_modal_dataset import package_modal_dataset
|
| 19 |
-
from finetune.train_schema import (
|
| 20 |
TrainValidationError,
|
| 21 |
validate_image_paths,
|
| 22 |
validate_lora_config,
|
|
@@ -25,14 +25,14 @@ from finetune.train_schema import (
|
|
| 25 |
|
| 26 |
MODAL_PROFILE = "marinaleitecabrera"
|
| 27 |
|
| 28 |
-
DEFAULT_CONFIG = Path("finetune/configs/minicpmv4_6_lora_sft_v2.yaml")
|
| 29 |
DEFAULT_PACKAGE = Path("finetune/modal_package")
|
| 30 |
DEFAULT_WORKSPACE = Path("finetune/workspace")
|
| 31 |
DEFAULT_LABELS = Path("finetune/labeled/v2/all.jsonl")
|
| 32 |
DEFAULT_TRAIN_JSON = Path("finetune/labeled/v2/all_train.json")
|
| 33 |
-
FIXTURE_LABELS = Path("finetune/fixtures/labels.jsonl")
|
| 34 |
-
FIXTURE_TRAIN_JSON = Path("finetune/fixtures/fixture_train.json")
|
| 35 |
-
FIXTURE_IMAGES = Path("finetune/fixtures/images")
|
| 36 |
|
| 37 |
|
| 38 |
def prepare_fixture_workspace(workspace: Path) -> None:
|
|
|
|
| 14 |
if str(_ROOT) not in sys.path:
|
| 15 |
sys.path.insert(0, str(_ROOT))
|
| 16 |
|
| 17 |
+
from finetune.vision.build_mixed_dataset import build_mixed
|
| 18 |
+
from finetune.vision.package_modal_dataset import package_modal_dataset
|
| 19 |
+
from finetune.vision.train_schema import (
|
| 20 |
TrainValidationError,
|
| 21 |
validate_image_paths,
|
| 22 |
validate_lora_config,
|
|
|
|
| 25 |
|
| 26 |
MODAL_PROFILE = "marinaleitecabrera"
|
| 27 |
|
| 28 |
+
DEFAULT_CONFIG = Path("finetune/vision/configs/minicpmv4_6_lora_sft_v2.yaml")
|
| 29 |
DEFAULT_PACKAGE = Path("finetune/modal_package")
|
| 30 |
DEFAULT_WORKSPACE = Path("finetune/workspace")
|
| 31 |
DEFAULT_LABELS = Path("finetune/labeled/v2/all.jsonl")
|
| 32 |
DEFAULT_TRAIN_JSON = Path("finetune/labeled/v2/all_train.json")
|
| 33 |
+
FIXTURE_LABELS = Path("finetune/vision/fixtures/labels.jsonl")
|
| 34 |
+
FIXTURE_TRAIN_JSON = Path("finetune/vision/fixtures/fixture_train.json")
|
| 35 |
+
FIXTURE_IMAGES = Path("finetune/vision/fixtures/images")
|
| 36 |
|
| 37 |
|
| 38 |
def prepare_fixture_workspace(workspace: Path) -> None:
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -14,7 +14,7 @@ if str(_ROOT) not in sys.path:
|
|
| 14 |
sys.path.insert(0, str(_ROOT))
|
| 15 |
sys.path.insert(0, str(_ROOT / "src"))
|
| 16 |
|
| 17 |
-
from finetune.v2_schema import EXTRACTABLE_KINDS, validate_v2_row
|
| 18 |
from vivamais.adapters.models.dspy_payloads import (
|
| 19 |
EXTRACTION_PROGRAMS,
|
| 20 |
LineItemFields,
|
|
|
|
| 14 |
sys.path.insert(0, str(_ROOT))
|
| 15 |
sys.path.insert(0, str(_ROOT / "src"))
|
| 16 |
|
| 17 |
+
from finetune.vision.v2_schema import EXTRACTABLE_KINDS, validate_v2_row
|
| 18 |
from vivamais.adapters.models.dspy_payloads import (
|
| 19 |
EXTRACTION_PROGRAMS,
|
| 20 |
LineItemFields,
|
|
@@ -107,7 +107,7 @@ def judge_corpus(limit: int = 0) -> str:
|
|
| 107 |
teacher_volume.reload()
|
| 108 |
|
| 109 |
from evals.judge_scoring import build_judge_prompt, is_accepted, parse_judge_verdict
|
| 110 |
-
from finetune.v2_schema import validate_v2_row
|
| 111 |
|
| 112 |
root = Path("/data")
|
| 113 |
rows = [
|
|
|
|
| 107 |
teacher_volume.reload()
|
| 108 |
|
| 109 |
from evals.judge_scoring import build_judge_prompt, is_accepted, parse_judge_verdict
|
| 110 |
+
from finetune.vision.v2_schema import validate_v2_row
|
| 111 |
|
| 112 |
root = Path("/data")
|
| 113 |
rows = [
|
|
@@ -80,23 +80,23 @@ export_image = (
|
|
| 80 |
"pip install 'transformers>=5.7.0,<6.0.0'",
|
| 81 |
)
|
| 82 |
.add_local_file(
|
| 83 |
-
local_path="finetune/patches/apply_llamafactory_loader_patch.py",
|
| 84 |
remote_path=f"{VIVAMAIS_REMOTE}/apply_llamafactory_loader_patch.py",
|
| 85 |
copy=True,
|
| 86 |
)
|
| 87 |
.run_commands(f"python {VIVAMAIS_REMOTE}/apply_llamafactory_loader_patch.py")
|
| 88 |
.add_local_file(
|
| 89 |
-
local_path="finetune/configs/minicpmv4_6_lora_export_v2.yaml",
|
| 90 |
remote_path=export_config_remote("v2"),
|
| 91 |
copy=True,
|
| 92 |
)
|
| 93 |
.add_local_file(
|
| 94 |
-
local_path="finetune/configs/minicpmv4_6_lora_export_v3.yaml",
|
| 95 |
remote_path=export_config_remote("v3"),
|
| 96 |
copy=True,
|
| 97 |
)
|
| 98 |
.add_local_file(
|
| 99 |
-
local_path="finetune/configs/minicpmv4_6_lora_export_v4.yaml",
|
| 100 |
remote_path=export_config_remote("v4"),
|
| 101 |
copy=True,
|
| 102 |
)
|
|
@@ -126,9 +126,7 @@ def _write_remote_export_config(version: str) -> Path:
|
|
| 126 |
return config_path
|
| 127 |
|
| 128 |
|
| 129 |
-
def _upload_from_container(
|
| 130 |
-
version: str, token: str, merged_repo: str, lora_repo: str
|
| 131 |
-
) -> None:
|
| 132 |
from huggingface_hub import HfApi
|
| 133 |
|
| 134 |
api = HfApi(token=token)
|
|
@@ -263,10 +261,7 @@ def main(
|
|
| 263 |
|
| 264 |
token = ""
|
| 265 |
if upload:
|
| 266 |
-
token = (
|
| 267 |
-
os.environ.get("HF_TOKEN", "").strip()
|
| 268 |
-
or os.environ.get("HF_API_KEY", "").strip()
|
| 269 |
-
)
|
| 270 |
if not token:
|
| 271 |
token = subprocess.run(
|
| 272 |
["hf", "auth", "token"], capture_output=True, text=True, check=True
|
|
|
|
| 80 |
"pip install 'transformers>=5.7.0,<6.0.0'",
|
| 81 |
)
|
| 82 |
.add_local_file(
|
| 83 |
+
local_path="finetune/vision/patches/apply_llamafactory_loader_patch.py",
|
| 84 |
remote_path=f"{VIVAMAIS_REMOTE}/apply_llamafactory_loader_patch.py",
|
| 85 |
copy=True,
|
| 86 |
)
|
| 87 |
.run_commands(f"python {VIVAMAIS_REMOTE}/apply_llamafactory_loader_patch.py")
|
| 88 |
.add_local_file(
|
| 89 |
+
local_path="finetune/vision/configs/minicpmv4_6_lora_export_v2.yaml",
|
| 90 |
remote_path=export_config_remote("v2"),
|
| 91 |
copy=True,
|
| 92 |
)
|
| 93 |
.add_local_file(
|
| 94 |
+
local_path="finetune/vision/configs/minicpmv4_6_lora_export_v3.yaml",
|
| 95 |
remote_path=export_config_remote("v3"),
|
| 96 |
copy=True,
|
| 97 |
)
|
| 98 |
.add_local_file(
|
| 99 |
+
local_path="finetune/vision/configs/minicpmv4_6_lora_export_v4.yaml",
|
| 100 |
remote_path=export_config_remote("v4"),
|
| 101 |
copy=True,
|
| 102 |
)
|
|
|
|
| 126 |
return config_path
|
| 127 |
|
| 128 |
|
| 129 |
+
def _upload_from_container(version: str, token: str, merged_repo: str, lora_repo: str) -> None:
|
|
|
|
|
|
|
| 130 |
from huggingface_hub import HfApi
|
| 131 |
|
| 132 |
api = HfApi(token=token)
|
|
|
|
| 261 |
|
| 262 |
token = ""
|
| 263 |
if upload:
|
| 264 |
+
token = os.environ.get("HF_TOKEN", "").strip() or os.environ.get("HF_API_KEY", "").strip()
|
|
|
|
|
|
|
|
|
|
| 265 |
if not token:
|
| 266 |
token = subprocess.run(
|
| 267 |
["hf", "auth", "token"], capture_output=True, text=True, check=True
|
|
@@ -37,7 +37,7 @@ image = (
|
|
| 37 |
modal.Image.debian_slim(python_version="3.11")
|
| 38 |
.pip_install("huggingface_hub", "pillow")
|
| 39 |
.add_local_file(
|
| 40 |
-
local_path="finetune/dataset_card_synthetic_ptbr.md",
|
| 41 |
remote_path=CARD_REMOTE,
|
| 42 |
copy=True,
|
| 43 |
)
|
|
|
|
| 37 |
modal.Image.debian_slim(python_version="3.11")
|
| 38 |
.pip_install("huggingface_hub", "pillow")
|
| 39 |
.add_local_file(
|
| 40 |
+
local_path="finetune/vision/dataset_card_synthetic_ptbr.md",
|
| 41 |
remote_path=CARD_REMOTE,
|
| 42 |
copy=True,
|
| 43 |
)
|