Update README.md
Browse files
README.md
CHANGED
|
@@ -1,71 +1,63 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
##
|
| 14 |
-
*
|
| 15 |
-
* **
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
raw_output = tokenizer.batch_decode(outputs, clean_up_tokenization_spaces=True)[0]
|
| 65 |
-
|
| 66 |
-
# 5. Extract Result
|
| 67 |
-
m = re.search(r'<\|im_start\|>assistant<\|im_sep\|>(.*?)<\|im_end\|>', raw_output, re.S)
|
| 68 |
-
result = m.group(1).strip() if m else raw_output.split("assistant")[-1].strip()
|
| 69 |
-
|
| 70 |
-
print(result)
|
| 71 |
-
# Expected Output: "12.40, old event"
|
|
|
|
| 1 |
+
# Dataset Card: Terminal Log Boundary Prediction (Streaming)
|
| 2 |
+
|
| 3 |
+
## 📋 Dataset Summary
|
| 4 |
+
This dataset is designed to train Large Language Models (LLMs) to detect phase transitions, or "boundaries," within continuous, timestamped terminal XML logs.
|
| 5 |
+
|
| 6 |
+
Instead of reading a massive log file all at once, the dataset is structured using a **sliding-window approach**. The model is fed a short history of terminal events and must determine if the **very last line** (the Target Line) represents the start of a new phase/event or just the continuation of an ongoing process.
|
| 7 |
+
|
| 8 |
+
## 🗂️ Dataset Structure
|
| 9 |
+
The dataset is provided in `JSONL` format, mapped specifically for conversational instruction-tuning (like ChatML). Each row contains three fields:
|
| 10 |
+
|
| 11 |
+
* **`instruction`**: The static system prompt that explicitly defines what makes a "new event" (e.g., shell prompts returning, phase transitions in automated scripts) versus an "old event" (e.g., a user pressing the Enter key, continuous downloading).
|
| 12 |
+
* **`input`**: The sliding-window terminal data. It is separated into two blocks:
|
| 13 |
+
* `### CONTEXT (Previous Events):` Up to 14 historical XML chunks to help the model understand the current state of the terminal.
|
| 14 |
+
* `### TARGET LINE (Extract and Classify THIS Timestamp):` The 15th chunk containing the specific timestamp the model needs to evaluate.
|
| 15 |
+
* **`label / output`**: The ground-truth prediction formatted strictly as `{timestamp}, {class} event`.
|
| 16 |
+
|
| 17 |
+
### Example Data Row
|
| 18 |
+
```json
|
| 19 |
+
{
|
| 20 |
+
"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\"...",
|
| 21 |
+
"input": "### CONTEXT (Previous Events):\n<system_output timestamp=\"10.01\">demo@server:~$ apt update</system_output>\n<system_output timestamp=\"10.05\">Reading package lists...</system_output>\n\n### TARGET LINE:\n<user_input timestamp=\"12.40\">s</user_input>",
|
| 22 |
+
"output": "12.40, old event"
|
| 23 |
+
}
|
| 24 |
+
🎯 The Model's Goal
|
| 25 |
+
The primary objective of the model is binary classification of sequential data. By looking at the historical context (e.g., "The terminal has been downloading packages for the last 14 steps"), the model must predict if the timestamp in the Target Line breaks that pattern and establishes a new boundary (e.g., "The download finished and the shell prompt returned").
|
| 26 |
+
|
| 27 |
+
✂️ Rules of Truncation
|
| 28 |
+
Raw terminal logs (like apt-get installations) can easily overflow an LLM's context window. To prevent this, the data engineering pipeline applies a strict Two-Phase Truncation rule:
|
| 29 |
+
|
| 30 |
+
Phase 1: Intra-Chunk Truncation (Line Limit)
|
| 31 |
+
If a single <system_output> block contains more than 15 lines of text, it is sliced. The first 5 lines and the last 5 lines are preserved, and the middle is replaced with a marker: ... [TRUNCATED X LINES] .... Note that <user_input> tags are never truncated to preserve human-interaction signals.
|
| 32 |
+
|
| 33 |
+
Phase 2: Window-Level Compression (Context Limit)
|
| 34 |
+
If the entire 14-chunk context window exceeds 25 total lines, the window is compressed:
|
| 35 |
+
|
| 36 |
+
The 5 oldest chunks and the 5 most recent chunks are kept fully intact.
|
| 37 |
+
|
| 38 |
+
For the chunks in the middle, the text is completely stripped out, leaving only the XML tags (e.g., <system_output timestamp="X">... [TRUNCATED TO SAVE SPACE] ...</system_output>).
|
| 39 |
+
This preserves the chronological timeline and sequence of events without bloating the token count.
|
| 40 |
+
|
| 41 |
+
⚖️ Data Sampling & Balancing
|
| 42 |
+
In a typical terminal log, over 95% of the lines are "Old Events" (continuous output or typing), which would lead the model to simply guess the majority class. To force actual learning, this dataset uses Negative Downsampling:
|
| 43 |
+
|
| 44 |
+
New Events (Positives): 100% of detected boundaries are kept.
|
| 45 |
+
|
| 46 |
+
Old Events (Negatives): Downsampled so that there is exactly a 2:1 ratio (Two old events for every one new event).
|
| 47 |
+
|
| 48 |
+
Hard Negative Mining
|
| 49 |
+
When selecting which "Old Events" to keep for the 2:1 ratio, the algorithm prioritizes Hard Negatives. Specifically, it targets <user_input> tags that contain a newline character (\n). This teaches the model the difficult lesson that a user pressing "Enter" is often just a completion of an input phase, not necessarily a new logical event.
|
| 50 |
+
|
| 51 |
+
💻 How to Load the Dataset
|
| 52 |
+
You can load this dataset directly in Python using the Hugging Face datasets library:
|
| 53 |
+
|
| 54 |
+
Python
|
| 55 |
+
from datasets import load_dataset
|
| 56 |
+
|
| 57 |
+
# Load the dataset
|
| 58 |
+
dataset = load_dataset("Jaiccc/model0_boundary_predict_streaming", split="train")
|
| 59 |
+
|
| 60 |
+
# Optional: Split into training and validation
|
| 61 |
+
split = dataset.train_test_split(test_size=0.1, seed=42)
|
| 62 |
+
train_dataset = split["train"]
|
| 63 |
+
eval_dataset = split["test"]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|