Jaiccc commited on
Commit
4efdd76
·
verified ·
1 Parent(s): a9af78c

Create README.md

Browse files
Files changed (1) hide show
  1. README.md +61 -0
README.md ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Model Card: Streaming Terminal Log Boundary Predictor (Phi-4 LoRA)
2
+
3
+ ## 🤖 Model Details
4
+ * **Base Model:** `unsloth/Phi-4-unsloth-bnb-4bit` (14B Parameters)
5
+ * **Architecture:** LoRA Adapters (PEFT)
6
+ * **Task:** Binary Classification (Terminal Event Boundary Detection)
7
+ * **Quantization:** 4-bit (bitsandbytes)
8
+ * **Language:** English / Bash / Terminal XML
9
+
10
+ ## 🎯 Intended Use
11
+ This model is designed to parse continuous, timestamped terminal logs formatted in XML and determine if a specific line represents a "Boundary."
12
+ * **New Event:** The start of a new phase (e.g., a new user prompt appearing, or a transition from downloading to extracting).
13
+ * **Old Event:** A continuation of an ongoing process or a user keystroke (e.g., pressing Enter).
14
+
15
+ This is particularly useful for segmenting long, automated build logs (like `apt-get` installations or mirror syncs) into readable, distinct chronological events.
16
+
17
+ ## 🗂️ Training Data
18
+ The model was fine-tuned on the **[Jaiccc/model0_boundary_predict_streaming](https://huggingface.co/datasets/Jaiccc/model0_boundary_predict_streaming)** dataset.
19
+
20
+ The data utilizes a **sliding-window context of 15 chunks**:
21
+ * 14 chunks of historical context.
22
+ * 1 Target chunk to classify.
23
+ * Heavily imbalanced data was downsampled to a 2:1 (Old:New) ratio to prevent majority-class guessing.
24
+
25
+ ## 💻 How to Use (Inference)
26
+ Because this is a private repository, you must authenticate using your Hugging Face token. This model uses PEFT/LoRA, meaning it is highly memory-efficient.
27
+
28
+ ```python
29
+ import re
30
+ from unsloth import FastLanguageModel
31
+ from google.colab import userdata
32
+
33
+ # 1. Retrieve your secure token
34
+ hf_token = userdata.get('HF_TOKEN') # Or os.getenv("HF_TOKEN")
35
+
36
+ # 2. Load the Fine-Tuned Model
37
+ model, tokenizer = FastLanguageModel.from_pretrained(
38
+ model_name = "Jaiccc/model_0_streaming_timestamp",
39
+ max_seq_length = 4096,
40
+ load_in_4bit = True,
41
+ token = hf_token,
42
+ )
43
+ FastLanguageModel.for_inference(model)
44
+
45
+ # 3. Format your prompt (ChatML)
46
+ instruction = "Your task is to analyze terminal XML logs and determine whether the timestamp in the TARGET LINE belongs to a 'new event' or an 'old event'."
47
+ input_data = "### CONTEXT (Previous Events):\n<system_output timestamp=\"10.01\">demo@server:~$ apt update</system_output>\n\n### TARGET LINE:\n<user_input timestamp=\"12.40\">s</user_input>"
48
+
49
+ prompt = f"<|im_start|>user<|im_sep|>{instruction}\n\n{input_data}<|im_end|><|im_start|>assistant<|im_sep|>"
50
+ inputs = tokenizer(prompt, return_tensors="pt").input_ids.to("cuda")
51
+
52
+ # 4. Generate Prediction
53
+ outputs = model.generate(input_ids=inputs, max_new_tokens=64, use_cache=True, temperature=0.1)
54
+ raw_output = tokenizer.batch_decode(outputs, clean_up_tokenization_spaces=True)[0]
55
+
56
+ # 5. Extract Result
57
+ m = re.search(r'<\|im_start\|>assistant<\|im_sep\|>(.*?)<\|im_end\|>', raw_output, re.S)
58
+ result = m.group(1).strip() if m else raw_output.split("assistant")[-1].strip()
59
+
60
+ print(result)
61
+ # Expected Output: "12.40, old event"