chinmaygarde commited on
Commit
3f58c7c
·
unverified ·
1 Parent(s): 8aef93a

Initial commit.

Browse files
Files changed (12) hide show
  1. .gitignore +30 -0
  2. .python-version +1 -0
  3. README.md +0 -0
  4. config.json +28 -0
  5. hello.py +49 -0
  6. justfile +2 -0
  7. model.safetensors +3 -0
  8. pyproject.toml +13 -0
  9. tokenizer.json +0 -0
  10. tokenizer_config.json +14 -0
  11. training_args.bin +3 -0
  12. uv.lock +0 -0
.gitignore ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Python
2
+ __pycache__/
3
+ *.py[cod]
4
+ *.pyo
5
+ *.pyd
6
+ .Python
7
+ *.egg-info/
8
+ dist/
9
+ build/
10
+
11
+ # Virtual environment
12
+ .venv/
13
+ venv/
14
+ env/
15
+
16
+ # Training checkpoints (keep final model, ignore intermediate)
17
+ training_output/
18
+
19
+ # Environment
20
+ .env
21
+ .env.*
22
+
23
+ # OS
24
+ .DS_Store
25
+ Thumbs.db
26
+
27
+ # IDE
28
+ .vscode/
29
+ .idea/
30
+ *.swp
.python-version ADDED
@@ -0,0 +1 @@
 
 
1
+ 3.12
README.md ADDED
File without changes
config.json ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "activation": "gelu",
3
+ "architectures": [
4
+ "DistilBertForSequenceClassification"
5
+ ],
6
+ "attention_dropout": 0.1,
7
+ "bos_token_id": null,
8
+ "dim": 768,
9
+ "dropout": 0.1,
10
+ "dtype": "float32",
11
+ "eos_token_id": null,
12
+ "hidden_dim": 3072,
13
+ "initializer_range": 0.02,
14
+ "max_position_embeddings": 512,
15
+ "model_type": "distilbert",
16
+ "n_heads": 12,
17
+ "n_layers": 6,
18
+ "pad_token_id": 0,
19
+ "problem_type": "single_label_classification",
20
+ "qa_dropout": 0.1,
21
+ "seq_classif_dropout": 0.2,
22
+ "sinusoidal_pos_embds": false,
23
+ "tie_weights_": true,
24
+ "tie_word_embeddings": true,
25
+ "transformers_version": "5.3.0",
26
+ "use_cache": false,
27
+ "vocab_size": 30522
28
+ }
hello.py ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from transformers import (
2
+ AutoTokenizer,
3
+ AutoModelForSequenceClassification,
4
+ TrainingArguments,
5
+ Trainer,
6
+ )
7
+ from datasets import load_dataset
8
+
9
+ # Load a small subset of IMDB reviews
10
+ dataset = load_dataset("imdb", split="train[:500]")
11
+ dataset = dataset.train_test_split(test_size=0.2, seed=42)
12
+
13
+ # Use DistilBERT — small, fast, good enough for a demo
14
+ model_name = "distilbert/distilbert-base-uncased"
15
+ tokenizer = AutoTokenizer.from_pretrained(model_name)
16
+ model = AutoModelForSequenceClassification.from_pretrained(model_name, num_labels=2)
17
+
18
+
19
+ def tokenize(batch):
20
+ return tokenizer(batch["text"], truncation=True, padding="max_length", max_length=128)
21
+
22
+
23
+ dataset = dataset.map(tokenize, batched=True)
24
+
25
+ trainer = Trainer(
26
+ model=model,
27
+ args=TrainingArguments(
28
+ output_dir="./training_output",
29
+ num_train_epochs=2,
30
+ per_device_train_batch_size=8,
31
+ logging_steps=25,
32
+ save_strategy="epoch",
33
+ ),
34
+ train_dataset=dataset["train"],
35
+ eval_dataset=dataset["test"],
36
+ )
37
+
38
+ # Train
39
+ trainer.train()
40
+
41
+ # Evaluate
42
+ results = trainer.evaluate()
43
+ print(f"Eval accuracy proxy (loss): {results['eval_loss']:.4f}")
44
+
45
+ # Save the model and tokenizer to the repo directory
46
+ trainer.save_model(".")
47
+ tokenizer.save_pretrained(".")
48
+
49
+ print("Done! Model and tokenizer saved to current directory.")
justfile ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ main:
2
+ uv run hello.py
model.safetensors ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:bbc6af1fce00266a50502c0f51837e9a4b7bee649978e8a7ed86db4764b47e64
3
+ size 267832560
pyproject.toml ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [project]
2
+ name = "hello"
3
+ version = "0.1.0"
4
+ description = "First HuggingFace Model."
5
+ readme = "README.md"
6
+ requires-python = ">=3.12"
7
+ dependencies = [
8
+ "datasets>=4.8.3",
9
+ "huggingface-hub>=1.7.2",
10
+ "torch>=2.10.0",
11
+ "transformers>=5.3.0",
12
+ "accelerate>=1.1.0",
13
+ ]
tokenizer.json ADDED
The diff for this file is too large to render. See raw diff
 
tokenizer_config.json ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "backend": "tokenizers",
3
+ "cls_token": "[CLS]",
4
+ "do_lower_case": true,
5
+ "is_local": false,
6
+ "mask_token": "[MASK]",
7
+ "model_max_length": 512,
8
+ "pad_token": "[PAD]",
9
+ "sep_token": "[SEP]",
10
+ "strip_accents": null,
11
+ "tokenize_chinese_chars": true,
12
+ "tokenizer_class": "BertTokenizer",
13
+ "unk_token": "[UNK]"
14
+ }
training_args.bin ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:3bb551b84787de66b16266b640ee4887d5ffee24fb770d28c231433d327e9262
3
+ size 5201
uv.lock ADDED
The diff for this file is too large to render. See raw diff