Download stackgo/stackbuild/model.py from s0duku/the-stack-go: direct link, hf CLI and curl.
- Browser
- Download file 2.59 kB
-
https://huggingface.co/datasets/s0duku/the-stack-go/resolve/main/stackgo/stackbuild/model.py
- Command line
-
hf download hf://datasets/s0duku/the-stack-go/stackgo/stackbuild/model.py
-
curl -L -o model.py https://huggingface.co/datasets/s0duku/the-stack-go/resolve/main/stackgo/stackbuild/model.py
2.59 kB
| """Immutable configuration and output models for repository sample building.""" | |
| from __future__ import annotations | |
| from dataclasses import dataclass, field | |
| from typing import Any, Mapping | |
| BEGIN_REPO_NAME = "<|begin▁of▁repo▁name|>" | |
| END_REPO_NAME = "<|end▁of▁repo▁name|>" | |
| BEGIN_FILE_NAME = "<|begin▁of▁file▁name|>" | |
| END_FILE_NAME = "<|end▁of▁file▁name|>" | |
| BEGIN_FILE = "<|begin▁of▁file|>" | |
| END_FILE = "<|end▁of▁file|>" | |
| SPECIAL_TOKENS = ( | |
| BEGIN_REPO_NAME, | |
| END_REPO_NAME, | |
| BEGIN_FILE_NAME, | |
| END_FILE_NAME, | |
| BEGIN_FILE, | |
| END_FILE, | |
| ) | |
| class BuildConfig: | |
| """Controls deterministic repository sample construction. | |
| ``max_tokens`` is enforced with the supplied tokenizer, or the pinned | |
| DeepSeek V4 Flash Base tokenizer by default. | |
| """ | |
| max_tokens: int = 8_192 | |
| min_tokens: int = 1 | |
| max_file_tokens: int | None = None | |
| include_weak_edges: bool = False | |
| metadata_only_vendor: bool = True | |
| metadata_only_generated: bool = True | |
| target_context: bool = False | |
| max_targets_per_repo: int = 32 | |
| max_dependency_depth: int = 3 | |
| utf8_bytes_per_token: float = 3.0 | |
| def __post_init__(self) -> None: | |
| if self.max_tokens < 64: | |
| raise ValueError("max_tokens must be at least 64") | |
| if self.min_tokens < 0 or self.min_tokens > self.max_tokens: | |
| raise ValueError("min_tokens must be between 0 and max_tokens") | |
| if self.max_file_tokens is not None and self.max_file_tokens < 1: | |
| raise ValueError("max_file_tokens must be positive") | |
| if self.max_targets_per_repo < 0: | |
| raise ValueError("max_targets_per_repo must be non-negative") | |
| if self.max_dependency_depth < 0: | |
| raise ValueError("max_dependency_depth must be non-negative") | |
| if self.utf8_bytes_per_token <= 0: | |
| raise ValueError("utf8_bytes_per_token must be positive") | |
| class SampleFile: | |
| """Provenance for one repository file represented in a sample.""" | |
| path: str | |
| relation: str | |
| content_policy: str | |
| role: str = "unknown" | |
| language: str | None = None | |
| bytes: int = 0 | |
| part: int = 1 | |
| parts: int = 1 | |
| class Sample: | |
| """One rendered training document and its complete provenance.""" | |
| sample_id: str | |
| repo_id: str | |
| revision_id: str | |
| kind: str | |
| text: str | |
| files: tuple[SampleFile, ...] | |
| token_count: int | |
| metadata: Mapping[str, Any] = field(default_factory=dict) | |