leochen085 commited on
Commit
327fd7e
·
verified ·
1 Parent(s): 96a058b

Update username to leochen085; fix base checkpoint download snippet

Browse files
Files changed (2) hide show
  1. README.md +16 -11
  2. modeling_slip.py +4 -4
README.md CHANGED
@@ -12,8 +12,8 @@ tags:
12
  base_model:
13
  - google/gemma-3-270m
14
  datasets:
15
- - LeoChen085/SlipDataset
16
- - LeoChen085/SlipSFTDataset
17
  pipeline_tag: feature-extraction
18
  ---
19
 
@@ -25,9 +25,9 @@ Yuliang Chen, Arvind Pillai, Yu Yvonne Wu, Tess Z. Griffin, Lisa Marsch, Michael
25
 
26
  *Dartmouth College*
27
 
28
- [[Paper]](asset/manuscript.pdf) [[Code]](https://github.com/yuc0805/SLIP) [[Llama variant]](https://huggingface.co/LeoChen085/SLIP-Llama) [[Dataset]](https://huggingface.co/datasets/LeoChen085/SlipDataset) [[SFT Dataset]](https://huggingface.co/datasets/LeoChen085/SlipSFTDataset)
29
 
30
- > **Backbone variants:** Gemma-3-270M (this repo) · [Llama-3.2-1B](https://huggingface.co/LeoChen085/SLIP-Llama)
31
 
32
  ---
33
 
@@ -84,13 +84,18 @@ pip install -r requirement.txt
84
  Download checkpoints:
85
 
86
  ```python
 
87
  from huggingface_hub import hf_hub_download
 
88
 
89
- hf_hub_download("LeoChen085/SLIP", "SLIP_gemma270.pth", local_dir="ckpt")
 
 
 
90
 
91
  # Optional: task-specific SFT checkpoints
92
  for name in ["har", "sleep", "ecg", "tsqa", "caption"]:
93
- hf_hub_download("LeoChen085/SLIP", f"{name}.safetensors", local_dir="ckpt")
94
  ```
95
 
96
  ## Quick Start
@@ -100,7 +105,7 @@ for name in ["har", "sleep", "ecg", "tsqa", "caption"]:
100
  ```python
101
  from transformers import AutoModel, AutoTokenizer
102
 
103
- model = AutoModel.from_pretrained("LeoChen085/SLIP", trust_remote_code=True)
104
  tokenizer = AutoTokenizer.from_pretrained("google/gemma-3-270m")
105
  model.eval()
106
  ```
@@ -179,7 +184,7 @@ with torch.no_grad():
179
  from huggingface_hub import hf_hub_download
180
  from safetensors.torch import load_file
181
 
182
- har_path = hf_hub_download("LeoChen085/SLIP", "har.safetensors")
183
  result = model.load_state_dict(load_file(har_path, device=str(device)), strict=False)
184
  print(f"Loaded HAR checkpoint — missing: {len(result.missing_keys)}, unexpected: {len(result.unexpected_keys)}")
185
  ```
@@ -209,16 +214,16 @@ from util.dataset import SftDataset, SFTCollator
209
  device = "cuda" if torch.cuda.is_available() else "cpu"
210
 
211
  # 1. Load base model and tokenizer
212
- model = AutoModel.from_pretrained("LeoChen085/SLIP", trust_remote_code=True)
213
  tokenizer = AutoTokenizer.from_pretrained("google/gemma-3-270m")
214
  model.eval().to(device)
215
 
216
  # 2. Swap in the HAR SFT checkpoint
217
- har_path = hf_hub_download("LeoChen085/SLIP", "har.safetensors")
218
  model.load_state_dict(load_file(har_path, device=str(device)), strict=False)
219
 
220
  # 3. Load SFT test data (auto-downloaded from HuggingFace)
221
- test_set = SftDataset("har_cot", split="test", hf_repo="LeoChen085/SlipSFTDataset")
222
  # is_test=True feeds only the prompt; answer is held out for evaluation
223
  loader = DataLoader(test_set, batch_size=8,
224
  collate_fn=SFTCollator(tokenizer, max_len=2880, is_test=True))
 
12
  base_model:
13
  - google/gemma-3-270m
14
  datasets:
15
+ - leochen085/SlipDataset
16
+ - leochen085/SlipSFTDataset
17
  pipeline_tag: feature-extraction
18
  ---
19
 
 
25
 
26
  *Dartmouth College*
27
 
28
+ [[Paper]](asset/manuscript.pdf) [[Code]](https://github.com/yuc0805/SLIP) [[Llama variant]](https://huggingface.co/leochen085/SLIP-Llama) [[Dataset]](https://huggingface.co/datasets/leochen085/SlipDataset) [[SFT Dataset]](https://huggingface.co/datasets/leochen085/SlipSFTDataset)
29
 
30
+ > **Backbone variants:** Gemma-3-270M (this repo) · [Llama-3.2-1B](https://huggingface.co/leochen085/SLIP-Llama)
31
 
32
  ---
33
 
 
84
  Download checkpoints:
85
 
86
  ```python
87
+ import os, torch
88
  from huggingface_hub import hf_hub_download
89
+ from safetensors.torch import load_file
90
 
91
+ # Base model, saved as the {"model": state_dict} .pth the training/eval scripts load
92
+ os.makedirs("ckpt", exist_ok=True)
93
+ state_dict = load_file(hf_hub_download("leochen085/SLIP", "model.safetensors"))
94
+ torch.save({"model": state_dict}, "ckpt/SLIP_gemma270.pth")
95
 
96
  # Optional: task-specific SFT checkpoints
97
  for name in ["har", "sleep", "ecg", "tsqa", "caption"]:
98
+ hf_hub_download("leochen085/SLIP", f"{name}.safetensors", local_dir="ckpt")
99
  ```
100
 
101
  ## Quick Start
 
105
  ```python
106
  from transformers import AutoModel, AutoTokenizer
107
 
108
+ model = AutoModel.from_pretrained("leochen085/SLIP", trust_remote_code=True)
109
  tokenizer = AutoTokenizer.from_pretrained("google/gemma-3-270m")
110
  model.eval()
111
  ```
 
184
  from huggingface_hub import hf_hub_download
185
  from safetensors.torch import load_file
186
 
187
+ har_path = hf_hub_download("leochen085/SLIP", "har.safetensors")
188
  result = model.load_state_dict(load_file(har_path, device=str(device)), strict=False)
189
  print(f"Loaded HAR checkpoint — missing: {len(result.missing_keys)}, unexpected: {len(result.unexpected_keys)}")
190
  ```
 
214
  device = "cuda" if torch.cuda.is_available() else "cpu"
215
 
216
  # 1. Load base model and tokenizer
217
+ model = AutoModel.from_pretrained("leochen085/SLIP", trust_remote_code=True)
218
  tokenizer = AutoTokenizer.from_pretrained("google/gemma-3-270m")
219
  model.eval().to(device)
220
 
221
  # 2. Swap in the HAR SFT checkpoint
222
+ har_path = hf_hub_download("leochen085/SLIP", "har.safetensors")
223
  model.load_state_dict(load_file(har_path, device=str(device)), strict=False)
224
 
225
  # 3. Load SFT test data (auto-downloaded from HuggingFace)
226
+ test_set = SftDataset("har_cot", split="test", hf_repo="leochen085/SlipSFTDataset")
227
  # is_test=True feeds only the prompt; answer is held out for evaluation
228
  loader = DataLoader(test_set, batch_size=8,
229
  collate_fn=SFTCollator(tokenizer, max_len=2880, is_test=True))
modeling_slip.py CHANGED
@@ -4,8 +4,8 @@ Self-contained model file for HuggingFace Hub (trust_remote_code=True).
4
 
5
  Usage:
6
  from transformers import AutoModel, AutoTokenizer
7
- model = AutoModel.from_pretrained("LeoChen085/SLIP", trust_remote_code=True, device_map="auto")
8
- tokenizer = AutoTokenizer.from_pretrained("LeoChen085/SLIP", trust_remote_code=True)
9
 
10
  # Raw (bs, nvar, L) time series -> SLIP sensor input
11
  sensors = model.process_sensor(torch.randn(2, 3, 320), patch_size=32)
@@ -13,7 +13,7 @@ Usage:
13
  # Task-specific checkpoint (download manually):
14
  from huggingface_hub import hf_hub_download
15
  from safetensors.torch import load_file
16
- state_dict = load_file(hf_hub_download("LeoChen085/SLIP", "har.safetensors"))
17
  model.load_state_dict(state_dict, strict=False)
18
  """
19
 
@@ -508,7 +508,7 @@ class SLIPModel(SLIPPreTrainedModel):
508
  SLIP: Sensor Language Integrated Pre-training.
509
 
510
  Usage:
511
- model = AutoModel.from_pretrained("LeoChen085/SLIP", trust_remote_code=True)
512
  """
513
 
514
  process_sensor = staticmethod(process_sensor)
 
4
 
5
  Usage:
6
  from transformers import AutoModel, AutoTokenizer
7
+ model = AutoModel.from_pretrained("leochen085/SLIP", trust_remote_code=True, device_map="auto")
8
+ tokenizer = AutoTokenizer.from_pretrained("leochen085/SLIP", trust_remote_code=True)
9
 
10
  # Raw (bs, nvar, L) time series -> SLIP sensor input
11
  sensors = model.process_sensor(torch.randn(2, 3, 320), patch_size=32)
 
13
  # Task-specific checkpoint (download manually):
14
  from huggingface_hub import hf_hub_download
15
  from safetensors.torch import load_file
16
+ state_dict = load_file(hf_hub_download("leochen085/SLIP", "har.safetensors"))
17
  model.load_state_dict(state_dict, strict=False)
18
  """
19
 
 
508
  SLIP: Sensor Language Integrated Pre-training.
509
 
510
  Usage:
511
+ model = AutoModel.from_pretrained("leochen085/SLIP", trust_remote_code=True)
512
  """
513
 
514
  process_sensor = staticmethod(process_sensor)