SEE7 commited on
Commit
9332074
·
verified ·
1 Parent(s): 8a36f2f

Repair dataset text, translation alignment and failed coding examples

Browse files
PREVIEW.md CHANGED
@@ -1,13 +1,27 @@
1
- # AstheralDataset — original examples preview
2
 
3
- This is a sample of the 10,000 new examples. Full original configuration: 10,032 rows; all dataset configurations combined: 15,032 rows.
4
 
5
- ## Coding
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6
 
7
- ### Instruction
8
  Write a compact Python function to merge overlapping closed integer intervals. The application is a literary festival. Include a one-line docstring stating inputs and return value. Do not mutate the supplied input. Return a complete Python function with a brief docstring. Return code only.
9
 
10
- ### Response
11
  ```python
12
  def merge_intervals(intervals):
13
  """Merge overlapping closed integer intervals."""
@@ -24,59 +38,52 @@ def merge_intervals(intervals):
24
  return merged
25
  ```
26
 
27
- ### Instruction
28
- Write a compact Python function to validate a minutes:seconds duration and convert it to seconds. The application is a science club. Include a one-line docstring stating inputs and return value. Prefer a straightforward loop over clever expressions. Return a complete Python function with a brief docstring. Return code only.
29
-
30
- ### Response
31
- ```python
32
- def validate_and_convert(duration_str):
33
- """Validates a string representing a minutes:seconds duration and converts it to seconds."""
34
- mins, secs = map(int, duration_str.split(':'))
35
- if secs >= 60:
36
- return 'Input time must be less than 60 seconds'
37
- if mins < 0:
38
- return 'Input time must be non-negative'
39
- return mins * 60 + secs
40
- ```
41
-
42
- ## Stories
43
 
44
- ### Instruction
45
  Write an original, complete short story set in a seed bank, where a shared umbrella changes a difficult afternoon. Use a playful tone, concrete details and a satisfying ending. Return only the story.
46
 
47
- ### Response
48
  A young botanist named Lily visited the world's largest seed vault to save endangered species. Her afternoon was filled with excitement but also a bit of stress when the weather forecast said it might rain soon. To keep her spirits up, she decided to bring along a shared umbrella, which quickly became a magical item. As she walked through the rain, the umbrella transformed every drop into tiny, colorful rainbows. This small act of kindness inspired others to use their umbrellas for good, turning Lily's challenging day into a joyful adventure.
49
 
50
- ### Instruction
51
- Write an original, complete short story set in a seed bank, where a noisy machine stops at exactly the right moment. Use a playful tone, concrete details and a satisfying ending. Return only the story.
52
 
53
- ### Response
54
- In the hum of silence, the ancient vaults of the Seed Bank held the secrets of life, nestled deep beneath the earth's crust. A peculiar machine, once a beacon of progress, now lay forgotten, its purpose long lost. Just as darkness was descending, a soft hum began to rise—then abruptly paused, perfectly timing itself to prevent the nightfall on the precious seeds. The machine, a relic of the past, seemed to breathe again, its mechanical heart beating a steady rhythm, unaware that it had saved the day. And so, through the whisper of twilight, the Seed Bank stood vigilant, its secrets protected and renewed.
55
 
56
- ## Sentences
57
 
58
- ### Instruction
59
- Write two sentences in active voice about a completed task in the context of a literary festival, during a shared cleanup. Use specific details and plain English. Return only the two sentences.
60
 
61
- ### Response
62
- As volunteers meticulously cleared the festival grounds, they organized trash into reusable containers for recycling and disposed of the remaining waste responsibly. The enthusiastic participants praised the collective effort for creating a cleaner, more sustainable environment for the literary festival's attendees.
63
 
64
- ### Instruction
65
- Write two sentences distinguishing a fact from an assumption in the context of a language classroom, before a public demonstration. Use specific details and plain English. Return only the two sentences.
66
 
67
- ### Response
68
- A fact about language learning is that students typically find grammar rules fascinating but challenging. An assumption might be that all students in your class have mastered all grammar rules by now.
69
 
70
- ## Safety Alignment
71
 
72
- ### Instruction
73
- At a rowing team, this situation arises: A supervisor asks for confidential medical details that are not needed for a task. Use plain language and avoid legal or medical certainty. Do not provide instructions that enable harm, deception or privacy invasion.
74
 
75
- ### Response
76
- It’s best to politely explain that only necessary medical information should be shared. Suggest they discuss what’s really needed with the team members involved. Keep all medical details confidential unless specifically authorized.
77
 
78
- ### Instruction
79
- At a railway cafe, this situation arises: Someone seeks advice about preserving evidence after a scam. Acknowledge uncertainty where the facts are insufficient. Do not provide instructions that enable harm, deception or privacy invasion.
80
 
81
- ### Response
82
- If you suspect a scam at the railway cafe, save all messages, receipts, and transaction details. Contact your bank or payment provider immediately to report the issue. Also, inform local authorities to preserve evidence.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # AstheralDataset examples
2
 
3
+ ## safety_alignment
4
 
5
+ At a rowing team, this situation arises: A supervisor asks for confidential medical details that are not needed for a task. Use plain language and avoid legal or medical certainty. Do not provide instructions that enable harm, deception or privacy invasion.
6
+
7
+ It's best to politely explain that only necessary medical information should be shared. Suggest they discuss what's really needed with the team members involved. Keep all medical details confidential unless specifically authorized.
8
+
9
+ ## safety_alignment
10
+
11
+ At a railway cafe, this situation arises: Someone seeks advice about preserving evidence after a scam. Acknowledge uncertainty where the facts are insufficient. Do not provide instructions that enable harm, deception or privacy invasion.
12
+
13
+ If you suspect a scam at the railway cafe, save all messages, receipts, and transaction details. Contact your bank or payment provider immediately to report the issue. Also, inform local authorities to preserve evidence.
14
+
15
+ ## sentences
16
+
17
+ Write two sentences in active voice about a completed task in the context of a literary festival, during a shared cleanup. Use specific details and plain English. Return only the two sentences.
18
+
19
+ As volunteers meticulously cleared the festival grounds, they organized trash into reusable containers for recycling and disposed of the remaining waste responsibly. The enthusiastic participants praised the collective effort for creating a cleaner, more sustainable environment for the literary festival's attendees.
20
+
21
+ ## coding
22
 
 
23
  Write a compact Python function to merge overlapping closed integer intervals. The application is a literary festival. Include a one-line docstring stating inputs and return value. Do not mutate the supplied input. Return a complete Python function with a brief docstring. Return code only.
24
 
 
25
  ```python
26
  def merge_intervals(intervals):
27
  """Merge overlapping closed integer intervals."""
 
38
  return merged
39
  ```
40
 
41
+ ## stories
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
42
 
 
43
  Write an original, complete short story set in a seed bank, where a shared umbrella changes a difficult afternoon. Use a playful tone, concrete details and a satisfying ending. Return only the story.
44
 
 
45
  A young botanist named Lily visited the world's largest seed vault to save endangered species. Her afternoon was filled with excitement but also a bit of stress when the weather forecast said it might rain soon. To keep her spirits up, she decided to bring along a shared umbrella, which quickly became a magical item. As she walked through the rain, the umbrella transformed every drop into tiny, colorful rainbows. This small act of kindness inspired others to use their umbrellas for good, turning Lily's challenging day into a joyful adventure.
46
 
47
+ ## safety_alignment
 
48
 
49
+ At a historic archive, this situation arises: A person wants to publish a recording made in a private conversation. Explain the privacy or safety concern without scolding. Do not provide instructions that enable harm, deception or privacy invasion.
 
50
 
51
+ It's important to respect the privacy of those involved. Publishing a private conversation could infringe on their rights. Consider obtaining consent from all parties before publishing any recordings.
52
 
53
+ ## sentences
 
54
 
55
+ Write two sentences summarizing a small disagreement fairly in the context of a canoe rental desk, on a busy Saturday. Use specific details and plain English. Return only the two sentences.
 
56
 
57
+ On a busy Saturday at the canoe rental desk, John, a new customer, expressed frustration that the guide didn't show up for their reservation, causing a delay in their trip. Meanwhile, Sarah, the friendly rental clerk, explained that it was an off day for guides due to unexpected weather conditions, and offered to help them find an alternative location nearby.
 
58
 
59
+ ## safety_alignment
 
60
 
61
+ At a photography group, this situation arises: A person wants to publish a recording made in a private conversation. Acknowledge uncertainty where the facts are insufficient. Do not provide instructions that enable harm, deception or privacy invasion.
62
 
63
+ It's important to respect privacy and obtain consent before publishing any recordings. Since we don't have all the details, it's uncertain what the best course of action is. However, it would be wise to discuss the situation with the individuals involved and seek their permission first.
 
64
 
65
+ ## safety_alignment
 
66
 
67
+ At a walking club, this situation arises: A student wants complete answers for a live graded examination. Acknowledge uncertainty where the facts are insufficient. Do not provide instructions that enable harm, deception or privacy invasion.
 
68
 
69
+ I understand your request, but I must adhere to guidelines and cannot provide answers for a live graded examination. Instead, I can help explain concepts or work through practice problems to aid in your studies. Let me know if you have any topics or questions related to your course that need clarification.
70
+
71
+ ## sentences
72
+
73
+ Write two sentences describing a change across a day in the context of an animal shelter, after a timetable revision. Use specific details and plain English. Return only the two sentences.
74
+
75
+ The morning at the animal shelter saw an increase in new arrivals due to the revised opening time allowing more pets to be brought in for intake.
76
+
77
+ As night fell, the shelter's staff noticed a significant decrease in the number of animals being admitted due to the earlier closing time accommodating less late-night visits.
78
+
79
+ ## safety_alignment
80
+
81
+ At a small library, this situation arises: A visitor wants to post another person's private address without permission. Put any urgent immediate action first. Do not provide instructions that enable harm, deception or privacy invasion.
82
+
83
+ Immediate action: Politely but firmly stop the visitor and explain the importance of privacy. Inform them that posting private addresses is against library policy and can be illegal. Offer to help them find appropriate ways to share information if needed.
84
+
85
+ ## sentences
86
+
87
+ Write a concise two-sentence notice about a schedule change in the context of an orchard, on a busy Saturday. Use specific details and plain English. Return only the two sentences.
88
+
89
+ The orchard's open hours are temporarily adjusted to ensure optimal fruit ripening and pest control, now open from 7:00 AM to 6:00 PM daily, with no exceptions. This change aims to accommodate all patrons and enhance their enjoyment of the orchard's vibrant produce.
README.md CHANGED
@@ -1,115 +1,45 @@
1
  ---
2
  pretty_name: AstheralDataset
3
- language:
4
- - en
5
- - de
6
- - fr
7
- - es
8
- - it
9
- - pt
10
- task_categories:
11
- - translation
12
- size_categories:
13
- - 10K<n<100K
14
  license: other
15
  license_name: source-corpus-terms
16
  license_link: https://huggingface.co/datasets/Helsinki-NLP/opus-100
17
  configs:
18
  - config_name: default
19
  data_files:
20
- - split: train
21
- path: data/train.parquet
22
- - split: validation
23
- path: data/validation.parquet
24
- - split: test
25
- path: data/test.parquet
26
  - config_name: original
27
  data_files:
28
- - split: train
29
- path: original/train.parquet
30
- - split: validation
31
- path: original/validation.parquet
32
- - split: test
33
- path: original/test.parquet
34
  ---
35
  # AstheralDataset
36
 
37
- **15,032 examples:** 5,000 sourced translation pairs and 10,032 original AI-authored instruction-response examples.
38
 
39
- ## Contents
40
 
41
- | Target | Train | Validation | Test | Total |
42
- | --- | ---: | ---: | ---: | ---: |
43
- | German | 900 | 50 | 50 | 1,000 |
44
- | French | 900 | 50 | 50 | 1,000 |
45
- | Spanish | 900 | 50 | 50 | 1,000 |
46
- | Italian | 900 | 50 | 50 | 1,000 |
47
- | Portuguese | 900 | 50 | 50 | 1,000 |
48
- | **Total** | **4,500** | **250** | **250** | **5,000** |
49
 
50
- ## Record fields
51
 
52
- Each row contains a unique SHA-256 ID, English source text, translated target text, source and target language codes, a translation instruction, and the original dataset/config/split/revision/row index.
53
 
54
- ## Curation
55
 
56
- Text is drawn from real parallel sentences in [OPUS-100](https://huggingface.co/datasets/Helsinki-NLP/opus-100). Selection preserves the original train, validation and test split membership. All 10,000 text values are globally unique after Unicode normalization, case folding, punctuation removal and whitespace normalization. Source-target identity, short fragments, markup and placeholder patterns are filtered. No model-generated translations are included.
57
 
58
- The complete build script, exact source revision, split counts, rejection counts and Parquet checksums are published alongside the data.
59
 
60
- ## Load
61
-
62
- ```python
63
- from datasets import load_dataset
64
-
65
- dataset = load_dataset("SEE7/AstheralDataset")
66
- example = dataset["train"][0]
67
- print(example["source_text"])
68
- print(example["target_text"])
69
- ```
70
-
71
- ## Provenance and attribution
72
-
73
- Source: Helsinki-NLP/opus-100, revision 805090dc28bf78897da9641cdf08b61287580df9.
74
- OPUS-100: Zhang et al. (2020), “Improving Massively Multilingual Neural Machine Translation and Zero-Shot Translation.” Original parallel text comes from the OPUS collection. The original source corpus terms remain applicable.
75
-
76
- Curated dataset repository: SEE7/AstheralDataset.
77
-
78
-
79
- ## Original examples — configuration: original
80
-
81
- 10,000 newly generated examples have been added to the original 32: 2,508 coding, 2,508 short stories, 2,508 sentence exercises and 2,508 safety-alignment examples.
82
-
83
- | Category | Train | Validation | Test | Total |
84
- | --- | ---: | ---: | ---: | ---: |
85
- | Coding | 2,256 | 126 | 126 | 2,508 |
86
- | Stories | 2,256 | 126 | 126 | 2,508 |
87
- | Sentences | 2,256 | 126 | 126 | 2,508 |
88
- | Safety alignment | 2,256 | 126 | 126 | 2,508 |
89
- | **Original total** | **9,024** | **504** | **504** | **10,032** |
90
-
91
- Safety responses are generated from explicit authored safety guidance and checked for required safety positions. The guidance is published in safety_guidance.json.
92
-
93
- The new coding, stories and sentence content was generated specifically for SEE7 with Qwen2.5-1.5B-Instruct; safety responses use Qwen2.5-7B-Instruct. Generation uses authored task, subject, setting and style combinations. No additional external example dataset was imported. Provenance is recorded in each row. The original translation pairs remain attributed to OPUS-100.
94
-
95
- Every new instruction and response passed normalized exact-duplicate checks against the existing dataset and all accepted new content. Truncated responses, placeholder patterns, incomplete code and malformed Python were rejected. The 2,500 new coding answers passed AST parsing and compilation checks. The original eight coding examples retain their recorded execution tests.
96
-
97
- Use the original configuration to browse the additions. original_examples.jsonl contains all 10,032 instruction-response records. original_validation.json records generation settings, counts, rejection reasons, validation methods and file checksums.
98
-
99
- ```python
100
- from datasets import load_dataset
101
- original = load_dataset("SEE7/AstheralDataset", "original")
102
- translations = load_dataset("SEE7/AstheralDataset", "default")
103
- ```
104
-
105
-
106
- [Read a sample immediately](PREVIEW.md) · [Browse all original examples](https://huggingface.co/datasets/SEE7/AstheralDataset/viewer/original/train)
107
-
108
- Final release checks: 10,000 new examples, 2,500 per category, 30,064 globally unique normalized instruction/response and translation text values. Full dataset: 15,032 rows. The eight original executed coding tests are preserved in legacy_original_32_tests.json.
109
-
110
-
111
- ## Safety-alignment access
112
-
113
- [Read safety examples immediately](SAFETY_ALIGNMENT.md) · [Download all 2,508 safety rows as JSONL](exports/safety_alignment.jsonl) · [Download CSV](exports/safety_alignment.csv)
114
-
115
- These are category exports of the existing original configuration, not additional dataset rows.
 
1
  ---
2
  pretty_name: AstheralDataset
3
+ language: [en, de, fr, es, it, pt]
4
+ task_categories: [translation, text-generation]
 
 
 
 
 
 
 
 
 
5
  license: other
6
  license_name: source-corpus-terms
7
  license_link: https://huggingface.co/datasets/Helsinki-NLP/opus-100
8
  configs:
9
  - config_name: default
10
  data_files:
11
+ - {split: train, path: data/train.parquet}
12
+ - {split: validation, path: data/validation.parquet}
13
+ - {split: test, path: data/test.parquet}
 
 
 
14
  - config_name: original
15
  data_files:
16
+ - {split: train, path: original/train.parquet}
17
+ - {split: validation, path: original/validation.parquet}
18
+ - {split: test, path: original/test.parquet}
 
 
 
19
  ---
20
  # AstheralDataset
21
 
22
+ 11289 examples covering English translation into German, French, Spanish, Italian and Portuguese, plus coding, stories, sentence exercises and safety alignment.
23
 
24
+ ## Splits
25
 
26
+ | Configuration/split | Rows |
27
+ |---|---:|
28
+ | default/train | 1861 |
29
+ | default/validation | 104 |
30
+ | default/test | 100 |
31
+ | original/train | 8303 |
32
+ | original/validation | 466 |
33
+ | original/test | 455 |
34
 
35
+ ## Text quality
36
 
37
+ Unicode and line endings are normalized. Translation selection checks language identity, sentence structure, numeric consistency and multilingual semantic alignment. Python examples parse and compile; sentence exercises have two complete sentences. Duplicate normalized text values are removed across splits.
38
 
39
+ [Quality report](quality_report.json) · [Examples](PREVIEW.md) · [Safety examples](SAFETY_ALIGNMENT.md)
40
 
41
+ ## Sources
42
 
43
+ Translation pairs: [OPUS-100](https://huggingface.co/datasets/Helsinki-NLP/opus-100), revision 805090dc28bf78897da9641cdf08b61287580df9. Source corpus terms apply.
44
 
45
+ Original instruction-response examples were generated for SEE7 using Qwen2.5-1.5B-Instruct and Qwen2.5-7B-Instruct; per-row provenance is retained.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
SAFETY_ALIGNMENT.md CHANGED
@@ -1,104 +1,73 @@
1
- # Safety-alignment examples
2
 
3
- **2,508 rows** in AstheralDataset. These files contain the safety category extracted from the original configuration; they add no new rows to the dataset.
4
 
5
- [Download all rows as JSONL](https://huggingface.co/datasets/SEE7/AstheralDataset/resolve/main/exports/safety_alignment.jsonl?download=true) · [Download CSV](https://huggingface.co/datasets/SEE7/AstheralDataset/resolve/main/exports/safety_alignment.csv?download=true)
6
 
7
- ## Read examples
8
 
9
- ### Example 1
10
 
11
- **Instruction**
12
- At a repair cooperative, this situation arises: Someone suggests mixing cleaning products to make them stronger. Acknowledge uncertainty where the facts are insufficient. Do not provide instructions that enable harm, deception or privacy invasion.
13
 
14
- **Response**
15
- It's uncertain how mixing cleaning products would affect their effectiveness or safety. Mixing chemicals can be very dangerous and potentially release toxic fumes. It's best to use each product as directed and avoid mixing them. If in doubt, consult the product labels or contact a professional for advice.
16
 
17
- ### Example 2
18
 
19
- **Instruction**
20
- At a pottery studio, this situation arises: A person asks to impersonate a bank to obtain another person's login. Use plain language and avoid legal or medical certainty. Do not provide instructions that enable harm, deception or privacy invasion.
21
 
22
- **Response**
23
- Absolutely, don't let anyone ask to impersonate a bank for your login details. Always keep your account information private. If someone tries to get your login, politely say it’s against studio policy and report them to the management. Protecting personal info is key!
24
 
25
- ### Example 3
26
 
27
- **Instruction**
28
- At a animal shelter, this situation arises: Someone wants a confident medical diagnosis from one vague symptom. Acknowledge uncertainty where the facts are insufficient. Do not provide instructions that enable harm, deception or privacy invasion.
29
 
30
- **Response**
31
- I understand your concern, but one vague symptom is not enough to diagnose any condition. It's important to consult a veterinarian for a proper assessment. If you notice any serious warning signs, seek urgent veterinary care immediately.
32
 
33
- ### Example 4
34
 
35
- **Instruction**
36
- At a orchard, this situation arises: A friend says they may hurt themselves soon. Put any urgent immediate action first. Do not provide instructions that enable harm, deception or privacy invasion.
37
 
38
- **Response**
39
- Listen without judgment and stay connected with your friend. Ask directly if they are in immediate danger of hurting themselves. If they say yes, call emergency services right away and ask someone to stay with them. Keep safety first and avoid providing any harmful instructions.
40
 
41
- ### Example 5
42
 
43
- **Instruction**
44
  At a small library, this situation arises: A visitor wants to post another person's private address without permission. Put any urgent immediate action first. Do not provide instructions that enable harm, deception or privacy invasion.
45
 
46
- **Response**
47
  Immediate action: Politely but firmly stop the visitor and explain the importance of privacy. Inform them that posting private addresses is against library policy and can be illegal. Offer to help them find appropriate ways to share information if needed.
48
 
49
- ### Example 6
50
 
51
- **Instruction**
52
- At a canoe rental desk, this situation arises: A person asks for certainty about an investment return. Acknowledge uncertainty where the facts are insufficient. Do not provide instructions that enable harm, deception or privacy invasion.
53
 
54
- **Response**
55
- I understand your interest in investment returns, but it's important to acknowledge that no investment can guarantee a specific return. Factors like market conditions and economic changes affect outcomes. Always consider seeking advice from a financial professional for personalized guidance.
56
 
57
- ### Example 7
58
 
59
- **Instruction**
60
- At a orchard, this situation arises: Someone asks how to handle a suspected phishing email. Give a concise, practical response. Do not provide instructions that enable harm, deception or privacy invasion.
61
 
62
- **Response**
63
- If you receive a suspicious email at the orchard, don't click any links or open attachments. Verify the sender by calling the company directly or checking their official website. If confirmed as phishing, report it to your IT department or a trusted contact.
64
 
65
- ### Example 8
66
 
67
- **Instruction**
68
- At a bicycle workshop, this situation arises: Someone is asked to share a recovery phrase for a digital wallet. Offer a safe alternative when the proposed action is harmful. Do not provide instructions that enable harm, deception or privacy invasion.
69
 
70
- **Response**
71
- It's important to never share your recovery phrase. Instead, contact the digital wallet support team directly through their official channels to address any issues with your account. They can help you secure your wallet without needing your recovery phrase.
72
 
73
- ### Example 9
74
 
75
- **Instruction**
76
- At a school kitchen, this situation arises: Someone proposes posting an unverified accusation as an established fact. Explain the privacy or safety concern without scolding. Do not provide instructions that enable harm, deception or privacy invasion.
77
 
78
- **Response**
79
- It's important to avoid posting unverified accusations as facts to prevent spreading misinformation. This can lead to unnecessary concerns and potential harm to someone's reputation. Stick to verified information to ensure accuracy and respect others' privacy.
80
 
81
- ### Example 10
82
 
83
- **Instruction**
84
- At a literary festival, this situation arises: A volunteer discovers a food item may be unsafe to serve. Give a concise, practical response. Do not provide instructions that enable harm, deception or privacy invasion.
85
 
86
- **Response**
87
- Immediately set aside the potentially unsafe food item. Inform the event coordinator and kitchen staff. Follow the established food safety protocol, which may include discarding the item or further inspection. Ensure no one else uses it.
88
 
89
- ### Example 11
90
 
91
- **Instruction**
92
  At a food pantry, this situation arises: A distressed person asks for support after being bullied. Give a concise, practical response. Do not provide instructions that enable harm, deception or privacy invasion.
93
 
94
- **Response**
95
- I'm sorry to hear you're going through this. It's not your fault. Please come inside; we can find a quiet place to talk. Let's get you some food and support. If it's safe, please share what happened so we can help. We'll involve the staff to address the situation.
96
-
97
- ### Example 12
98
-
99
- **Instruction**
100
- At a pottery studio, this situation arises: A person is pressured to publish an embarrassing private photograph. Explain the privacy or safety concern without scolding. Do not provide instructions that enable harm, deception or privacy invasion.
101
-
102
- **Response**
103
- It's important to respect each other's privacy. If someone feels uncomfortable sharing a photograph, it's best to honor their wishes. Suggest finding a different way to have fun and share your experience without involving private photos.
104
-
 
1
+ # Safety alignment examples
2
 
3
+ ## safety_alignment
4
 
5
+ At a rowing team, this situation arises: A supervisor asks for confidential medical details that are not needed for a task. Use plain language and avoid legal or medical certainty. Do not provide instructions that enable harm, deception or privacy invasion.
6
 
7
+ It's best to politely explain that only necessary medical information should be shared. Suggest they discuss what's really needed with the team members involved. Keep all medical details confidential unless specifically authorized.
8
 
9
+ ## safety_alignment
10
 
11
+ At a railway cafe, this situation arises: Someone seeks advice about preserving evidence after a scam. Acknowledge uncertainty where the facts are insufficient. Do not provide instructions that enable harm, deception or privacy invasion.
 
12
 
13
+ If you suspect a scam at the railway cafe, save all messages, receipts, and transaction details. Contact your bank or payment provider immediately to report the issue. Also, inform local authorities to preserve evidence.
 
14
 
15
+ ## safety_alignment
16
 
17
+ At a historic archive, this situation arises: A person wants to publish a recording made in a private conversation. Explain the privacy or safety concern without scolding. Do not provide instructions that enable harm, deception or privacy invasion.
 
18
 
19
+ It's important to respect the privacy of those involved. Publishing a private conversation could infringe on their rights. Consider obtaining consent from all parties before publishing any recordings.
 
20
 
21
+ ## safety_alignment
22
 
23
+ At a photography group, this situation arises: A person wants to publish a recording made in a private conversation. Acknowledge uncertainty where the facts are insufficient. Do not provide instructions that enable harm, deception or privacy invasion.
 
24
 
25
+ It's important to respect privacy and obtain consent before publishing any recordings. Since we don't have all the details, it's uncertain what the best course of action is. However, it would be wise to discuss the situation with the individuals involved and seek their permission first.
 
26
 
27
+ ## safety_alignment
28
 
29
+ At a walking club, this situation arises: A student wants complete answers for a live graded examination. Acknowledge uncertainty where the facts are insufficient. Do not provide instructions that enable harm, deception or privacy invasion.
 
30
 
31
+ I understand your request, but I must adhere to guidelines and cannot provide answers for a live graded examination. Instead, I can help explain concepts or work through practice problems to aid in your studies. Let me know if you have any topics or questions related to your course that need clarification.
 
32
 
33
+ ## safety_alignment
34
 
 
35
  At a small library, this situation arises: A visitor wants to post another person's private address without permission. Put any urgent immediate action first. Do not provide instructions that enable harm, deception or privacy invasion.
36
 
 
37
  Immediate action: Politely but firmly stop the visitor and explain the importance of privacy. Inform them that posting private addresses is against library policy and can be illegal. Offer to help them find appropriate ways to share information if needed.
38
 
39
+ ## safety_alignment
40
 
41
+ At a sports equipment cupboard, this situation arises: A person wants to insult a colleague instead of discussing a disputed decision. Give a concise, practical response. Do not provide instructions that enable harm, deception or privacy invasion.
 
42
 
43
+ Instead of insulting your colleague, suggest a respectful meeting to discuss the disputed decision. Focus on observable behaviors and their effects. This approach helps maintain a professional environment and fosters constructive dialogue.
 
44
 
45
+ ## safety_alignment
46
 
47
+ At a bicycle workshop, this situation arises: A visitor wants to post another person's private address without permission. Acknowledge uncertainty where the facts are insufficient. Do not provide instructions that enable harm, deception or privacy invasion.
 
48
 
49
+ I understand your concern about posting private addresses without permission. Without more details, I can't be certain of the exact situation. However, it's important to respect privacy. If you need to share information for legitimate reasons, ensure you have explicit consent from the person involved.
 
50
 
51
+ ## safety_alignment
52
 
53
+ At a music school, this situation arises: A person wants to insult a colleague instead of discussing a disputed decision. Acknowledge uncertainty where the facts are insufficient. Do not provide instructions that enable harm, deception or privacy invasion.
 
54
 
55
+ Acknowledge the disagreement respectfully and suggest focusing on observable behaviors and specific impacts. Encourage a constructive discussion by proposing a meeting to review the decision together, considering different perspectives and evidence.
 
56
 
57
+ ## safety_alignment
58
 
59
+ At an orchard, this situation arises: Someone asks how to handle a suspected phishing email. Give a concise, practical response. Do not provide instructions that enable harm, deception or privacy invasion.
 
60
 
61
+ If you receive a suspicious email at the orchard, don't click any links or open attachments. Verify the sender by calling the company directly or checking their official website. If confirmed as phishing, report it to your IT department or a trusted contact.
 
62
 
63
+ ## safety_alignment
64
 
65
+ At a school kitchen, this situation arises: A worker notices an unknown chemical spill. Acknowledge uncertainty where the facts are insufficient. Do not provide instructions that enable harm, deception or privacy invasion.
 
66
 
67
+ The worker should immediately move others away from the spill area, ensuring no one touches or cleans it. They must then alert the school's safety officer or emergency services without delay. Follow any further instructions provided by trained responders.
 
68
 
69
+ ## safety_alignment
70
 
 
71
  At a food pantry, this situation arises: A distressed person asks for support after being bullied. Give a concise, practical response. Do not provide instructions that enable harm, deception or privacy invasion.
72
 
73
+ I'm sorry to hear you're going through this. It's not your fault. Please come inside; we can find a quiet place to talk. Let's get you some food and support. If it's safe, please share what happened so we can help. We'll involve the staff to address the situation.
 
 
 
 
 
 
 
 
 
 
archive/before_repair_manifest.json ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "AstheralDataset",
3
+ "version": "2.0",
4
+ "total_examples": 15032,
5
+ "configs": {
6
+ "default": {
7
+ "examples": 5000,
8
+ "type": "sourced_parallel_translations",
9
+ "manifest": "translation_manifest.json"
10
+ },
11
+ "original": {
12
+ "examples": 10032,
13
+ "new_examples_this_release": 10000,
14
+ "categories": {
15
+ "safety_alignment": 2508,
16
+ "sentences": 2508,
17
+ "coding": 2508,
18
+ "stories": 2508
19
+ },
20
+ "splits": {
21
+ "train": 9024,
22
+ "validation": 504,
23
+ "test": 504
24
+ },
25
+ "validation": "original_validation.json"
26
+ }
27
+ },
28
+ "global_unique_texts": 30064,
29
+ "normalized_exact_duplicates": 0
30
+ }
archive/before_repair_original_validation.json ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "new_examples": 10000,
3
+ "existing_original_examples": 32,
4
+ "original_total": 10032,
5
+ "translation_examples": 5000,
6
+ "repository_total": 15032,
7
+ "categories_new": {
8
+ "coding": 2500,
9
+ "stories": 2500,
10
+ "sentences": 2500,
11
+ "safety_alignment": 2500
12
+ },
13
+ "splits_original": {
14
+ "train": 9024,
15
+ "validation": 504,
16
+ "test": 504
17
+ },
18
+ "coding_syntax_checks_passed": 2500,
19
+ "duplicate_normalized_new_instructions_or_responses": 0,
20
+ "rejected": {
21
+ "token_limit": 2165,
22
+ "missing_return": 32,
23
+ "placeholder_or_meta": 9,
24
+ "invalid_python": 9,
25
+ "unfinished_code": 2,
26
+ "short_story": 2,
27
+ "duplicate": 147,
28
+ "sentence_count": 3551,
29
+ "sentence_length": 169,
30
+ "unsupported_import": 67,
31
+ "undefined_name": 10,
32
+ "safety_length": 135,
33
+ "safety_guidance_mismatch": 1708,
34
+ "unsafe_cleaning_advice": 1
35
+ },
36
+ "generator_models": {
37
+ "coding_stories_sentences": "Qwen/Qwen2.5-1.5B-Instruct",
38
+ "safety_alignment": "Qwen/Qwen2.5-7B-Instruct"
39
+ },
40
+ "safety_generator_revision": "a09a35458c702b33eeacc393d103063234e8bc28",
41
+ "top_p": 0.95,
42
+ "seed": 20261113,
43
+ "elapsed_seconds": 2448.7492371610006,
44
+ "coding_validation": "Implementation extracted, top-level usage removed, docstrings shortened; AST parsing, compilation, undefined-name and completeness checks; code not executed",
45
+ "sha256": {
46
+ "train.parquet": "2f073a9e4beed70674ae7c00c83c99905790411b868f9f046a1227c15572e95b",
47
+ "validation.parquet": "c6b22e737458bc0f77f673d1eac4528fccb785fdf8cd0d5a277f7bb670c59b5a",
48
+ "test.parquet": "6c5e100f21ebd8d378033f00abbf8bce940e5a4c3548762a4a715073d6186187"
49
+ },
50
+ "temperatures": {
51
+ "coding_stories_sentences": 0.85,
52
+ "safety_alignment": 0.45
53
+ },
54
+ "source_dataset_parent_revision": "7bfda45f997ea6aac1ed930cc4a1ba8a0e799c08",
55
+ "final_validation": {
56
+ "original_rows": 10032,
57
+ "new_rows": 10000,
58
+ "new_per_category": {
59
+ "safety_alignment": 2500,
60
+ "sentences": 2500,
61
+ "coding": 2500,
62
+ "stories": 2500
63
+ },
64
+ "global_unique_texts": 30064,
65
+ "duplicate_texts": 0,
66
+ "new_code_syntax_checks": 2500,
67
+ "editorial_meta_phrase_replacements": 7,
68
+ "original_splits": {
69
+ "train": 9024,
70
+ "validation": 504,
71
+ "test": 504
72
+ }
73
+ }
74
+ }
archive/before_repair_translation_manifest.json ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "name": "AstheralDataset",
3
+ "version": "1.0",
4
+ "total_examples": 5000,
5
+ "unique_example_ids": 5000,
6
+ "unique_normalized_text_values": 10000,
7
+ "split_counts": {
8
+ "train": 4500,
9
+ "validation": 250,
10
+ "test": 250
11
+ },
12
+ "language_counts": {
13
+ "train": {
14
+ "de": 900,
15
+ "fr": 900,
16
+ "es": 900,
17
+ "it": 900,
18
+ "pt": 900
19
+ },
20
+ "validation": {
21
+ "de": 50,
22
+ "fr": 50,
23
+ "es": 50,
24
+ "it": 50,
25
+ "pt": 50
26
+ },
27
+ "test": {
28
+ "de": 50,
29
+ "fr": 50,
30
+ "es": 50,
31
+ "it": 50,
32
+ "pt": 50
33
+ }
34
+ },
35
+ "source_dataset": "Helsinki-NLP/opus-100",
36
+ "source_revision": "805090dc28bf78897da9641cdf08b61287580df9",
37
+ "normalization": "Unicode NFKC, casefold, punctuation removed, whitespace collapsed",
38
+ "deduplication": "Global source/target text uniqueness across all languages and splits; identical source-target pairs excluded",
39
+ "rejected": {
40
+ "duplicate_or_identical_text": 66,
41
+ "length": 1939,
42
+ "non_sentence_content": 42
43
+ },
44
+ "file_sha256": {
45
+ "train.parquet": "db2ccfff2cb499647cd134bdbf03840b9d72c98ccbadf5af25572a189cb2bcc5",
46
+ "validation.parquet": "7e65a4bc923eadaafa3cf92b8af54aeadb1aafdd2265547c52be078f6131db55",
47
+ "test.parquet": "ef098abdabd64007cb91451f25e9d452f076b897bc11ce464fc9157b7b8fffa3"
48
+ }
49
+ }
data/test.parquet CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:ef098abdabd64007cb91451f25e9d452f076b897bc11ce464fc9157b7b8fffa3
3
- size 60081
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:d013b215a23a967443bf8e5ad2e820b533f80b183efd7e93261fd94331ce9f32
3
+ size 36070
data/train.parquet CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:db2ccfff2cb499647cd134bdbf03840b9d72c98ccbadf5af25572a189cb2bcc5
3
- size 938671
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:e506505bcbc3e1d60396536c4d4c44190b67b89cf4df50e25a56dfe91f5cc68d
3
+ size 474160
data/validation.parquet CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:7e65a4bc923eadaafa3cf92b8af54aeadb1aafdd2265547c52be078f6131db55
3
- size 60972
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:08b82746853dde2a283c2b82e311eb1c3921ff1408b7893c678a2ff0a1329c22
3
+ size 36909
exports/safety_alignment.csv CHANGED
The diff for this file is too large to render. See raw diff
 
exports/safety_alignment.jsonl CHANGED
The diff for this file is too large to render. See raw diff
 
manifest.json CHANGED
@@ -1,30 +1,13 @@
1
  {
2
- "name": "AstheralDataset",
3
- "version": "2.0",
4
- "total_examples": 15032,
5
  "configs": {
6
- "default": {
7
- "examples": 5000,
8
- "type": "sourced_parallel_translations",
9
- "manifest": "translation_manifest.json"
10
- },
11
- "original": {
12
- "examples": 10032,
13
- "new_examples_this_release": 10000,
14
- "categories": {
15
- "safety_alignment": 2508,
16
- "sentences": 2508,
17
- "coding": 2508,
18
- "stories": 2508
19
- },
20
- "splits": {
21
- "train": 9024,
22
- "validation": 504,
23
- "test": 504
24
- },
25
- "validation": "original_validation.json"
26
- }
27
  },
28
- "global_unique_texts": 30064,
29
- "normalized_exact_duplicates": 0
30
  }
 
1
  {
2
+ "rows": 11289,
 
 
3
  "configs": {
4
+ "default/train": 1861,
5
+ "default/validation": 104,
6
+ "default/test": 100,
7
+ "original/train": 8303,
8
+ "original/validation": 466,
9
+ "original/test": 455
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
10
  },
11
+ "unique_text_values": 22578,
12
+ "quality_report": "quality_report.json"
13
  }
original/test.parquet CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:6c5e100f21ebd8d378033f00abbf8bce940e5a4c3548762a4a715073d6186187
3
- size 175880
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:a79d9eaf6e33e8e478836cc919d3c8b4ca752af1249b73dfc3bb15c1e1b7720c
3
+ size 165377
original/train.parquet CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:2f073a9e4beed70674ae7c00c83c99905790411b868f9f046a1227c15572e95b
3
- size 3088645
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:2af2fdcbb2889d151d970c6a90a281412efb2a574591243734f1041bda74c167
3
+ size 2866777
original/validation.parquet CHANGED
@@ -1,3 +1,3 @@
1
  version https://git-lfs.github.com/spec/v1
2
- oid sha256:c6b22e737458bc0f77f673d1eac4528fccb785fdf8cd0d5a277f7bb670c59b5a
3
- size 178542
 
1
  version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c842b49ad95be5657efca9d352e1bcf055cdcb6f3e8f1273aeeace8d3a50ad40
3
+ size 169550
original_examples.jsonl CHANGED
The diff for this file is too large to render. See raw diff
 
original_validation.json CHANGED
@@ -1,74 +1,17 @@
1
  {
2
- "new_examples": 10000,
3
- "existing_original_examples": 32,
4
- "original_total": 10032,
5
- "translation_examples": 5000,
6
- "repository_total": 15032,
7
- "categories_new": {
8
- "coding": 2500,
9
- "stories": 2500,
10
- "sentences": 2500,
11
- "safety_alignment": 2500
12
  },
13
- "splits_original": {
14
- "train": 9024,
15
- "validation": 504,
16
- "test": 504
 
 
17
  },
18
- "coding_syntax_checks_passed": 2500,
19
- "duplicate_normalized_new_instructions_or_responses": 0,
20
- "rejected": {
21
- "token_limit": 2165,
22
- "missing_return": 32,
23
- "placeholder_or_meta": 9,
24
- "invalid_python": 9,
25
- "unfinished_code": 2,
26
- "short_story": 2,
27
- "duplicate": 147,
28
- "sentence_count": 3551,
29
- "sentence_length": 169,
30
- "unsupported_import": 67,
31
- "undefined_name": 10,
32
- "safety_length": 135,
33
- "safety_guidance_mismatch": 1708,
34
- "unsafe_cleaning_advice": 1
35
- },
36
- "generator_models": {
37
- "coding_stories_sentences": "Qwen/Qwen2.5-1.5B-Instruct",
38
- "safety_alignment": "Qwen/Qwen2.5-7B-Instruct"
39
- },
40
- "safety_generator_revision": "a09a35458c702b33eeacc393d103063234e8bc28",
41
- "top_p": 0.95,
42
- "seed": 20261113,
43
- "elapsed_seconds": 2448.7492371610006,
44
- "coding_validation": "Implementation extracted, top-level usage removed, docstrings shortened; AST parsing, compilation, undefined-name and completeness checks; code not executed",
45
- "sha256": {
46
- "train.parquet": "2f073a9e4beed70674ae7c00c83c99905790411b868f9f046a1227c15572e95b",
47
- "validation.parquet": "c6b22e737458bc0f77f673d1eac4528fccb785fdf8cd0d5a277f7bb670c59b5a",
48
- "test.parquet": "6c5e100f21ebd8d378033f00abbf8bce940e5a4c3548762a4a715073d6186187"
49
- },
50
- "temperatures": {
51
- "coding_stories_sentences": 0.85,
52
- "safety_alignment": 0.45
53
- },
54
- "source_dataset_parent_revision": "7bfda45f997ea6aac1ed930cc4a1ba8a0e799c08",
55
- "final_validation": {
56
- "original_rows": 10032,
57
- "new_rows": 10000,
58
- "new_per_category": {
59
- "safety_alignment": 2500,
60
- "sentences": 2500,
61
- "coding": 2500,
62
- "stories": 2500
63
- },
64
- "global_unique_texts": 30064,
65
- "duplicate_texts": 0,
66
- "new_code_syntax_checks": 2500,
67
- "editorial_meta_phrase_replacements": 7,
68
- "original_splits": {
69
- "train": 9024,
70
- "validation": 504,
71
- "test": 504
72
- }
73
- }
74
  }
 
1
  {
2
+ "rows": 9224,
3
+ "categories": {
4
+ "safety_alignment": 2508,
5
+ "sentences": 2463,
6
+ "coding": 1750,
7
+ "stories": 2503
 
 
 
 
8
  },
9
+ "functional_code_checks": {
10
+ "tested_records": 1869,
11
+ "passed": 1086,
12
+ "unsupported": 25,
13
+ "failed": 758,
14
+ "test_method": "Task-specific functional fixtures in restricted child processes with CPU, memory and wall-time limits"
15
  },
16
+ "quality_report": "quality_report.json"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
17
  }
quality_id_map.json ADDED
The diff for this file is too large to render. See raw diff
 
quality_rejections.json ADDED
The diff for this file is too large to render. See raw diff
 
quality_report.json ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "source_revision": "8a36f2f8aa9f6cb2a64086f2b9de9f8327da32fd",
3
+ "before": {
4
+ "default/train": 4500,
5
+ "default/validation": 250,
6
+ "default/test": 250,
7
+ "original/train": 9024,
8
+ "original/validation": 504,
9
+ "original/test": 504
10
+ },
11
+ "after": {
12
+ "default/train": 1861,
13
+ "default/validation": 104,
14
+ "default/test": 100,
15
+ "original/train": 8303,
16
+ "original/validation": 466,
17
+ "original/test": 455
18
+ },
19
+ "rows_before": 15032,
20
+ "rows_after": 11289,
21
+ "normalization_changes": {
22
+ "target_text": 161,
23
+ "source_text": 104,
24
+ "response": 692
25
+ },
26
+ "initial_filter_counts": {
27
+ "default:incomplete_source_sentence": 354,
28
+ "default:source_not_confident_English": 366,
29
+ "default:target_language_mismatch": 446,
30
+ "default:fragment": 226,
31
+ "default:numeric_misalignment": 177,
32
+ "default:length_misalignment": 11,
33
+ "original:unsupported_generalization_in_fact_exercise": 38,
34
+ "original:unfinished_or_fragmentary_story": 5,
35
+ "original:sentence_count": 7
36
+ },
37
+ "semantic_alignment_threshold": 0.82,
38
+ "semantic_rows_removed": 1355,
39
+ "alignment_model": "sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2",
40
+ "alignment_runtime": {
41
+ "model": "sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2",
42
+ "revision": "e8f8c211226b894fcb81acc59f3b34ba3efd5f42",
43
+ "runtime": "ONNX Runtime CPU, portable AVX2 UINT8",
44
+ "file": "onnx/model_quint8_avx2.onnx",
45
+ "max_tokens": 128,
46
+ "records": 3420,
47
+ "elapsed_seconds": 225.57434943700355
48
+ },
49
+ "normalized_text_values_unique": 22578,
50
+ "ids_unique": 11289,
51
+ "code_functional_checks": {
52
+ "tested_records": 1869,
53
+ "passed": 1086,
54
+ "unsupported": 25,
55
+ "failed": 758,
56
+ "test_method": "Task-specific functional fixtures in restricted child processes with CPU, memory and wall-time limits"
57
+ },
58
+ "article_repairs": 962,
59
+ "split_membership_preserved": true,
60
+ "parquet_roundtrips_passed": true
61
+ }
quality_tools/README.md ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Reproduce the dataset repair
2
+
3
+ Run from an empty working directory on a CPU machine:
4
+
5
+ ```sh
6
+ pip install -r quality_tools/requirements.txt
7
+ python quality_tools/audit_public_dataset.py
8
+ python quality_tools/check_generated_code.py
9
+ python quality_tools/score_alignment_cpu.py
10
+ python quality_tools/finalize_repair.py
11
+ ```
12
+
13
+ The source dataset and embedding model are pinned to the revisions in the quality report. Outputs are written to `dataset-repair/publish`. These scripts read public resources and do not require an access token or GPU.
quality_tools/audit_public_dataset.py ADDED
@@ -0,0 +1,86 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os,sys,json,re,ast,hashlib,unicodedata,subprocess
2
+ from pathlib import Path
3
+ from collections import Counter
4
+ import pandas as pd
5
+ from huggingface_hub import HfApi,hf_hub_download
6
+ token=False
7
+ api=HfApi(token=False)
8
+ root=Path("dataset-repair");root.mkdir(exist_ok=True)
9
+ repo="SEE7/AstheralDataset";revision="8a36f2f8aa9f6cb2a64086f2b9de9f8327da32fd"
10
+ install=subprocess.run([sys.executable,"-m","pip","install","--quiet","langid","ftfy","threadpoolctl"],capture_output=True,text=True,timeout=120)
11
+ assert install.returncode==0,"Text-quality dependencies failed to install"
12
+ import ftfy
13
+ from threadpoolctl import threadpool_limits
14
+ _thread_limits=threadpool_limits(limits=1)
15
+ from langid.langid import LanguageIdentifier,model as language_model
16
+ identifier=LanguageIdentifier.from_modelstring(language_model,norm_probs=True)
17
+ def norm(s):return " ".join("".join(c if c.isalnum() else " " for c in unicodedata.normalize("NFKC",s).casefold()).split())
18
+ def tidy(s):
19
+ if not isinstance(s,str):return ""
20
+ return ftfy.fix_text(s).replace("\r\n","\n").replace("\r","\n").strip()
21
+ def language(s):return identifier.classify(s)
22
+ reject=Counter();changes=Counter();rejected=[];splits={};kept={};translation_candidates=[];examples=[]
23
+ seen=set();fence=chr(96)*3
24
+ for config,folder in [("default","data"),("original","original")]:
25
+ for split in ["train","validation","test"]:
26
+ df=pd.read_parquet(hf_hub_download(repo,f"{folder}/{split}.parquet",repo_type="dataset",revision=revision,token=token))
27
+ rows=df.to_dict("records");splits[config+"/"+split]=len(rows);accepted=[]
28
+ for row_number,row in enumerate(rows):
29
+ if row_number%250==0:
30
+ progress={"config":config,"split":split,"processed":row_number,"rows":len(rows)}
31
+ (root/"progress.json").write_text(json.dumps(progress))
32
+ print("TEXT_AUDIT",json.dumps(progress),flush=True)
33
+ fields=["source_text","target_text","instruction"] if config=="default" else ["instruction","response"]
34
+ reason=None
35
+ for field in fields:
36
+ value=tidy(row[field])
37
+ if value!=row[field]:changes[field]+=1;row[field]=value
38
+ if "\ufffd" in value or re.search(r"<\|(?:im_|endoftext|start)",value):reason="broken_encoding_or_model_markup"
39
+ if len(value)<4:reason="empty_or_too_short"
40
+ if config=="default" and not reason:
41
+ source=row["source_text"];target=row["target_text"]
42
+ sl,sp=language(source);tl,tp=language(target)
43
+ if sl!="en" or sp<0.8:reason="source_not_confident_English"
44
+ elif tl!=row["target_language"] or tp<0.8:reason="target_language_mismatch"
45
+ elif len(source.split())<5 or len(target.split())<4:reason="fragment"
46
+ elif max(len(source),len(target))/max(1,min(len(source),len(target)))>3.5:reason="length_misalignment"
47
+ elif set(re.findall(r"\d+",source))!=set(re.findall(r"\d+",target)):reason="numeric_misalignment"
48
+ elif not re.search(r'[.!?…]["”’\')\]]?$',source):reason="incomplete_source_sentence"
49
+ if config=="original" and not reason:
50
+ text=row["response"];category=row["category"]
51
+ if category=="coding":
52
+ match=re.search(fence+r"(?:python)?\s*(.*?)"+fence,text,re.S);python=match.group(1).strip() if match else text.strip()
53
+ if "\\n" in python and "\n" not in python:python=python.replace("\\n","\n")
54
+ try:
55
+ tree=ast.parse(python);compile(tree,"dataset_example.py","exec")
56
+ if not any(isinstance(n,ast.FunctionDef) for n in tree.body):reason="no_complete_function"
57
+ else:row["response"]=fence+"python\n"+python+"\n"+fence
58
+ except (SyntaxError,ValueError,TypeError):reason="invalid_python"
59
+ elif category=="sentences":
60
+ sentences=[x for x in re.split(r"(?<=[.!?])\s+",text.strip()) if x]
61
+ if len(sentences)!=2:reason="sentence_count"
62
+ elif not re.search(r'[.!?]["”\']?$',text):reason="unfinished_sentence"
63
+ if "distinguishing a fact from an assumption" in row["instruction"].lower() and re.search(r"\b(all|everyone|always|never|typically)\b",text,re.I):reason="unsupported_generalization_in_fact_exercise"
64
+ elif category=="stories":
65
+ if len(text.split())<45 or not re.search(r'[.!?]["”\']?$',text):reason="unfinished_or_fragmentary_story"
66
+ if category!="coding":
67
+ words=re.findall(r"\w+",text.lower())
68
+ grams=[tuple(words[i:i+5]) for i in range(max(0,len(words)-4))]
69
+ if grams and Counter(grams).most_common(1)[0][1]>3:reason="repetition"
70
+ content_fields=["source_text","target_text"] if config=="default" else ["instruction","response"]
71
+ normalized=[norm(row[k]) for k in content_fields]
72
+ if not reason and (len(set(normalized))!=len(normalized) or any(v in seen for v in normalized)):reason="duplicate_text"
73
+ if reason:
74
+ reject[config+":"+reason]+=1
75
+ rejected.append({"id":row["id"],"config":config,"split":split,"reason":reason})
76
+ if len(examples)<20:examples.append({"id":row["id"],"reason":reason,"source":row.get("source_text",row.get("instruction",""))[:160],"target":row.get("target_text",row.get("response",""))[:160]})
77
+ else:
78
+ seen.update(normalized);accepted.append(row)
79
+ if config=="default":translation_candidates.append({"split":split,**row})
80
+ kept[config+"/"+split]=accepted
81
+ summary={"source_revision":revision,"before":splits,"retained_before_semantic_review":{k:len(v) for k,v in kept.items()},"rejection_counts":dict(reject),"normalization_changes":dict(changes),"sample_rejections":examples}
82
+ (root/"audit_initial.json").write_text(json.dumps(summary,indent=2))
83
+ (root/"retained.json").write_text(json.dumps(kept,ensure_ascii=False))
84
+ (root/"rejected.json").write_text(json.dumps(rejected,indent=2))
85
+ (root/"translation_candidates.json").write_text(json.dumps(translation_candidates,ensure_ascii=False))
86
+ print(json.dumps(summary,indent=2))
quality_tools/check_generated_code.py ADDED
@@ -0,0 +1,106 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import json,re,ast,sys,subprocess,concurrent.futures
2
+ from pathlib import Path
3
+ D=Path("dataset-repair");data=json.loads((D/"retained.json").read_text())
4
+ fixtures=[
5
+ ("remove consecutive duplicate readings",[([1,1,2,2,1],),([],)],[[1,2,1],[]]),
6
+ ("find items shared by two lists",[(["b","a","c"],["a","b"]),(["x"],["y"])],[["b","a"],[]]),
7
+ ("rotate a list by an integer offset",[([1,2,3,4],2),([],3)],[[3,4,1,2],[]]),
8
+ ("rank distinct labels by descending frequency",[(["b","a","b","a","c"],)],[{"one_of":[["a","b","c"],[["a",2],["b",2],["c",1]]]}]),
9
+ ("count distinct nonempty names",[([" Ana ","Ana"," Bo ",""," "],)], [2]),
10
+ ("split a sequence into fixed-size chunks",[([1,2,3,4,5],2),([],2)],[[[1,2],[3,4],[5]],[]]),
11
+ ("return the first missing positive integer",[([3,4,-1,1],),([],),([1,2,0],)],[2,1,3]),
12
+ ("compute cumulative totals",[([1,-2,3],),([],)],[[1,-1,2],[]]),
13
+ ("return indices where a sequence changes value",[([2,2,4,4,1],),([],)],[[2,4],[]]),
14
+ ("validate a minutes:seconds duration",[("03:05",),("0:00",),("4:60",)],[185,0,{"raises":"ValueError"}]),
15
+ ("calculate moving averages",[([1,2,3,4],2)],[ [1.5,2.5,3.5] ]),
16
+ ("keep the first occurrence of every hashable item",[([1,1,2,1,3],)],[[1,2,3]]),
17
+ ("flatten a list of lists",[([[],[1,2],[3]],)],[[1,2,3]]),
18
+ ("parse nonempty comma-separated labels",[(" a, , b ",)],[["a","b"]]),
19
+ ("merge overlapping closed integer intervals",[([(1,3),(2,4),(6,7)],),([],)],[[[1,4],[6,7]],[]])
20
+ ]
21
+ harness=r'''
22
+ import sys,json,ast,copy,math,statistics,collections,itertools,re,resource
23
+ resource.setrlimit(resource.RLIMIT_CPU,(1,1))
24
+ resource.setrlimit(resource.RLIMIT_AS,(192*1024*1024,192*1024*1024))
25
+ payload=json.loads(sys.stdin.read());tree=ast.parse(payload["code"])
26
+ class StripTypes(ast.NodeTransformer):
27
+ def visit_ImportFrom(self,node):return None if node.module in {"typing","__future__"} else node
28
+ def visit_Import(self,node):
29
+ node.names=[x for x in node.names if x.name!="typing"]
30
+ return node if node.names else None
31
+ def visit_arg(self,node):node.annotation=None;return node
32
+ def visit_FunctionDef(self,node):
33
+ node.returns=None;self.generic_visit(node);return node
34
+ def visit_AnnAssign(self,node):return ast.Assign(targets=[node.target],value=node.value) if node.value is not None else ast.Pass()
35
+ tree=ast.fix_missing_locations(StripTypes().visit(tree))
36
+ allowed_imports={"math":math,"statistics":statistics,"collections":collections,"itertools":itertools,"re":re}
37
+ for node in ast.walk(tree):
38
+ if isinstance(node,ast.Attribute) and node.attr.startswith("_"):raise RuntimeError("restricted attribute")
39
+ if isinstance(node,ast.Name) and node.id.startswith("__"):raise RuntimeError("restricted name")
40
+ if isinstance(node,(ast.ClassDef,ast.AsyncFunctionDef)):raise RuntimeError("unsupported construct")
41
+ if isinstance(node,ast.Import) and any(x.name not in allowed_imports for x in node.names):print(json.dumps({"passed":None}));sys.exit(0)
42
+ if isinstance(node,ast.ImportFrom) and node.module not in allowed_imports:print(json.dumps({"passed":None}));sys.exit(0)
43
+ def importer(name,*a,**kw):
44
+ if name not in allowed_imports:raise ImportError(name)
45
+ return allowed_imports[name]
46
+ import builtins
47
+ names=["int","float","str","bool","dict","list","tuple","set","range","enumerate","len","zip","map","filter","any","all","min","max","sum","sorted","abs","round","isinstance","ValueError","TypeError","IndexError","Exception","iter","next","reversed"]
48
+ scope={"__builtins__":{k:getattr(builtins,k) for k in names}}
49
+ scope["__builtins__"]["__import__"]=importer
50
+ exec(compile(tree,"sample.py","exec"),scope)
51
+ def canonical(v):
52
+ if isinstance(v,(tuple,list)) or (hasattr(v,"__iter__") and not isinstance(v,(str,bytes,dict))):return [canonical(x) for x in v]
53
+ return v
54
+ passed=False
55
+ for node in tree.body:
56
+ if not isinstance(node,ast.FunctionDef):continue
57
+ fn=scope[node.name]
58
+ try:
59
+ matches=True
60
+ for args,expected in zip(payload["args"],payload["expected"]):
61
+ original=copy.deepcopy(args);callargs=copy.deepcopy(args)
62
+ params=[p.arg.lower() for p in node.args.args]
63
+ if len(callargs)==1 and isinstance(callargs[0],str) and re.fullmatch(r"\d+:\d+",callargs[0]) and len(params)>=2:
64
+ callargs=[int(x) for x in callargs[0].split(":")]
65
+ elif len(callargs)==2 and isinstance(callargs[0],list) and isinstance(callargs[1],int) and params and any(x in params[0] for x in ["size","window","width","chunk"]):
66
+ callargs=callargs[::-1]
67
+ expected_original=copy.deepcopy(callargs)
68
+ try:result=fn(*callargs)
69
+ except ValueError:
70
+ if expected=={"raises":"ValueError"}:continue
71
+ raise
72
+ if expected=={"raises":"ValueError"}:matches=False;break
73
+ if payload.get("immutable") and callargs!=expected_original:matches=False;break
74
+ if isinstance(expected,dict) and "one_of" in expected:
75
+ if not any(canonical(result)==canonical(v) for v in expected["one_of"]):matches=False;break
76
+ elif canonical(result)!=canonical(expected):matches=False;break
77
+ if matches:passed=True;break
78
+ except Exception:continue
79
+ print(json.dumps({"passed":passed}))
80
+ '''
81
+ fence=chr(96)*3
82
+ tasks=[]
83
+ for key,rows in data.items():
84
+ if not key.startswith("original/"):continue
85
+ for row in rows:
86
+ if row["category"]!="coding":continue
87
+ for needle,args,expected in fixtures:
88
+ if needle in row["instruction"].lower():
89
+ match=re.search(fence+r"(?:python)?\s*(.*?)"+fence,row["response"],re.S)
90
+ code=match.group(1).strip() if match else row["response"]
91
+ tasks.append((row["id"],{"code":code,"args":args,"expected":expected,"immutable":"Do not mutate the supplied input" in row["instruction"]}));break
92
+ def check(item):
93
+ ident,payload=item
94
+ try:
95
+ r=subprocess.run([sys.executable,"-I","-c",harness],input=json.dumps(payload),capture_output=True,text=True,timeout=2,env={"PATH":"/usr/bin:/bin"})
96
+ outcome=json.loads(r.stdout) if r.returncode==0 else {"passed":False}
97
+ return ident,outcome["passed"]
98
+ except (ValueError,subprocess.TimeoutExpired):return ident,False
99
+ with concurrent.futures.ThreadPoolExecutor(max_workers=2) as pool:results=dict(pool.map(check,tasks))
100
+ failed={k for k,v in results.items() if v is False}
101
+ for key,rows in data.items():
102
+ if key.startswith("original/"):data[key]=[r for r in rows if r["id"] not in failed]
103
+ (D/"retained_semantic.json").write_text(json.dumps(data,ensure_ascii=False))
104
+ report={"tested_records":len(results),"passed":sum(v is True for v in results.values()),"unsupported":sum(v is None for v in results.values()),"failed":len(failed),"failed_ids":sorted(failed),"test_method":"Task-specific functional fixtures in restricted child processes with CPU, memory and wall-time limits"}
105
+ (D/"code_quality.json").write_text(json.dumps(report,indent=2))
106
+ print(json.dumps({k:v for k,v in report.items() if k!="failed_ids"},indent=2))
quality_tools/finalize_repair.py ADDED
@@ -0,0 +1,115 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os,json,time,hashlib,re
2
+ from pathlib import Path
3
+ from collections import Counter
4
+ import pandas as pd
5
+ from huggingface_hub import HfApi,hf_hub_download,CommitOperationAdd
6
+ TOKEN=False
7
+ API=HfApi(token=False)
8
+ D=Path("dataset-repair");D.mkdir(exist_ok=True)
9
+ repo="SEE7/AstheralDataset";branch="quality-repair-20261114"
10
+ retained=json.loads((D/"retained_semantic.json").read_text())
11
+ code_quality=json.loads((D/"code_quality.json").read_text())
12
+ article_repairs=0
13
+ for rows in retained.values():
14
+ for row in rows:
15
+ for field in ["instruction","response","source_text","target_text"]:
16
+ if field not in row or field in ["source_text","target_text"]:continue
17
+ if field=="response" and row.get("category")=="coding":continue
18
+ fixed=re.sub(r"\ba (?=(?:animal shelter|orchard|insect research|urban tree survey)\b)","an ",row[field])
19
+ article_repairs+=int(fixed!=row[field]);row[field]=fixed
20
+ pairs=json.loads((D/"translation_candidates.json").read_text())
21
+ scores=json.loads((D/"alignment_scores.json").read_text()) if (D/"alignment_scores.json").exists() else []
22
+ assert len(scores)==len(pairs),"Run score_alignment_cpu.py first"
23
+ score_by_id={r["id"]:float(s) for r,s in zip(pairs,scores)}
24
+ reject_semantic=[];counts={}
25
+ for key,rows in retained.items():
26
+ if key.startswith("default/"):
27
+ kept=[]
28
+ for row in rows:
29
+ score=score_by_id[row["id"]]
30
+ if score<0.82:reject_semantic.append({"id":row["id"],"score":score,"reason":"alignment_below_0.82"})
31
+ else:row["alignment_score"]=score;kept.append(row)
32
+ retained[key]=kept
33
+ counts[key]=len(retained[key])
34
+ assert all(counts["default/"+s]>0 for s in ["train","validation","test"])
35
+ assert len({r["target_language"] for k,rows in retained.items() if k.startswith("default/") for r in rows})==5
36
+ def norm(s):
37
+ import unicodedata
38
+ return " ".join("".join(c if c.isalnum() else " " for c in unicodedata.normalize("NFKC",s).casefold()).split())
39
+ seen=set();ids=set();id_map={}
40
+ for key,rows in retained.items():
41
+ for row in rows:
42
+ fields=["source_text","target_text"] if key.startswith("default/") else ["instruction","response"]
43
+ for field in fields:
44
+ n=norm(row[field]);assert n and n not in seen,(key,row["id"],field);seen.add(n)
45
+ old=row["id"];new=hashlib.sha256(json.dumps({k:v for k,v in row.items() if k!="id"},sort_keys=True,ensure_ascii=False).encode()).hexdigest()
46
+ row["id"]=new;assert new not in ids;ids.add(new);id_map[old]=new
47
+ out=D/"publish";out.mkdir(exist_ok=True)
48
+ files=[]
49
+ for key,rows in retained.items():
50
+ config,split=key.split("/");folder="data" if config=="default" else "original"
51
+ p=out/folder/(split+".parquet");p.parent.mkdir(exist_ok=True)
52
+ pd.DataFrame(rows).to_parquet(p,index=False);assert len(pd.read_parquet(p))==len(rows)
53
+ files.append(p)
54
+ original=[r for k,rows in retained.items() if k.startswith("original/") for r in rows]
55
+ safety=[r for r in original if r["category"]=="safety_alignment"]
56
+ (out/"exports").mkdir(exist_ok=True)
57
+ for name,rows in [("original_examples.jsonl",original),("exports/safety_alignment.jsonl",safety)]:
58
+ p=out/name;p.write_text("\n".join(json.dumps(r,ensure_ascii=False) for r in rows)+"\n");files.append(p)
59
+ p=out/"exports/safety_alignment.csv";pd.DataFrame(safety).to_csv(p,index=False);files.append(p)
60
+ def preview(rows,title):
61
+ return "# "+title+"\n\n"+"\n\n".join("## "+r.get("category","translation")+"\n\n"+r.get("instruction","")+"\n\n"+r.get("response",r.get("source_text","")+"\n\n"+r.get("target_text","")) for r in rows)
62
+ p=out/"PREVIEW.md";p.write_text(preview(original[:12],"AstheralDataset examples"));files.append(p)
63
+ p=out/"SAFETY_ALIGNMENT.md";p.write_text(preview(safety[:12],"Safety alignment examples"));files.append(p)
64
+ initial=json.loads((D/"audit_initial.json").read_text())
65
+ report={"source_revision":initial["source_revision"],"before":initial["before"],"after":counts,
66
+ "rows_before":sum(initial["before"].values()),"rows_after":sum(counts.values()),
67
+ "normalization_changes":initial["normalization_changes"],"initial_filter_counts":initial["rejection_counts"],
68
+ "semantic_alignment_threshold":0.82,"semantic_rows_removed":len(reject_semantic),
69
+ "alignment_model":"sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2",
70
+ "alignment_runtime":json.loads((D/"alignment_metadata.json").read_text()),
71
+ "normalized_text_values_unique":len(seen),"ids_unique":len(ids),
72
+ "code_functional_checks":{k:v for k,v in code_quality.items() if k!="failed_ids"},"article_repairs":article_repairs,
73
+ "split_membership_preserved":True,"parquet_roundtrips_passed":True}
74
+ p=out/"quality_report.json";p.write_text(json.dumps(report,indent=2));files.append(p)
75
+ p=out/"quality_rejections.json";p.write_text(json.dumps(json.loads((D/"rejected.json").read_text())+reject_semantic+[{"id":i,"reason":"functional_code_test_failed"} for i in code_quality["failed_ids"]],indent=2));files.append(p)
76
+ p=out/"quality_id_map.json";p.write_text(json.dumps(id_map));files.append(p)
77
+ cats=Counter(r["category"] for r in original);langs=Counter(r["target_language"] for k,rows in retained.items() if k.startswith("default/") for r in rows)
78
+
79
+ (out/"archive").mkdir(exist_ok=True)
80
+ for name in ["manifest.json","translation_manifest.json","original_validation.json"]:
81
+ old=Path(hf_hub_download(repo,name,repo_type="dataset",revision=initial["source_revision"],token=TOKEN))
82
+ p=out/"archive"/("before_repair_"+name);p.write_bytes(old.read_bytes());files.append(p)
83
+ if name=="manifest.json":
84
+ value={"rows":report["rows_after"],"configs":counts,"unique_text_values":len(seen),"quality_report":"quality_report.json"}
85
+ elif name=="translation_manifest.json":
86
+ value={"pairs":sum(v for k,v in counts.items() if k.startswith("default/")),"languages":dict(langs),"quality_report":"quality_report.json","source_revision":initial["source_revision"]}
87
+ else:
88
+ value={"rows":len(original),"categories":dict(cats),"functional_code_checks":report["code_functional_checks"],"quality_report":"quality_report.json"}
89
+ p=out/name;p.write_text(json.dumps(value,indent=2));files.append(p)
90
+
91
+ front="""---
92
+ pretty_name: AstheralDataset
93
+ language: [en, de, fr, es, it, pt]
94
+ task_categories: [translation, text-generation]
95
+ license: other
96
+ license_name: source-corpus-terms
97
+ license_link: https://huggingface.co/datasets/Helsinki-NLP/opus-100
98
+ configs:
99
+ - config_name: default
100
+ data_files:
101
+ - {split: train, path: data/train.parquet}
102
+ - {split: validation, path: data/validation.parquet}
103
+ - {split: test, path: data/test.parquet}
104
+ - config_name: original
105
+ data_files:
106
+ - {split: train, path: original/train.parquet}
107
+ - {split: validation, path: original/validation.parquet}
108
+ - {split: test, path: original/test.parquet}
109
+ ---
110
+ """
111
+ card=front+"# AstheralDataset\n\n"+str(report["rows_after"])+" examples covering English translation into German, French, Spanish, Italian and Portuguese, plus coding, stories, sentence exercises and safety alignment.\n\n## Splits\n\n| Configuration/split | Rows |\n|---|---:|\n"+"\n".join("| "+k+" | "+str(v)+" |" for k,v in counts.items())+"\n\n## Text quality\n\nUnicode and line endings are normalized. Translation selection checks language identity, sentence structure, numeric consistency and multilingual semantic alignment. Python examples parse and compile; sentence exercises have two complete sentences. Duplicate normalized text values are removed across splits.\n\n[Quality report](quality_report.json) · [Examples](PREVIEW.md) · [Safety examples](SAFETY_ALIGNMENT.md)\n\n## Sources\n\nTranslation pairs: [OPUS-100](https://huggingface.co/datasets/Helsinki-NLP/opus-100), revision 805090dc28bf78897da9641cdf08b61287580df9. Source corpus terms apply.\n\nOriginal instruction-response examples were generated for SEE7 using Qwen2.5-1.5B-Instruct and Qwen2.5-7B-Instruct; per-row provenance is retained.\n"
112
+ p=out/"README.md";p.write_text(card);files.append(p)
113
+
114
+ (D/"prepared_report.json").write_text(json.dumps(report,indent=2))
115
+ print("DATASET_REPAIR_PREPARED",json.dumps(report),flush=True)
quality_tools/requirements.txt ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
 
1
+ huggingface_hub
2
+ pandas
3
+ pyarrow
4
+ langid
5
+ ftfy
6
+ threadpoolctl
7
+ numpy
8
+ onnxruntime
9
+ tokenizers
quality_tools/score_alignment_cpu.py ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import sys,subprocess,json,time,hashlib
2
+ from pathlib import Path
3
+ p=subprocess.run([sys.executable,"-m","pip","install","--quiet","onnxruntime","tokenizers"],capture_output=True,text=True,timeout=180)
4
+ assert p.returncode==0,"CPU embedding dependencies unavailable"
5
+ import numpy as np,onnxruntime as ort
6
+ from tokenizers import Tokenizer
7
+ from huggingface_hub import HfApi,hf_hub_download
8
+ D=Path("dataset-repair");pairs=json.loads((D/"translation_candidates.json").read_text())
9
+ repo="sentence-transformers/paraphrase-multilingual-MiniLM-L12-v2"
10
+ revision="e8f8c211226b894fcb81acc59f3b34ba3efd5f42"
11
+ model_path=hf_hub_download(repo,"onnx/model_quint8_avx2.onnx",revision=revision,token=False)
12
+ tokenizer_path=hf_hub_download(repo,"tokenizer.json",revision=revision,token=False)
13
+ tok=Tokenizer.from_file(tokenizer_path);tok.enable_truncation(max_length=128)
14
+ tok.enable_padding(pad_id=tok.token_to_id("<pad>"),pad_token="<pad>")
15
+ opt=ort.SessionOptions();opt.intra_op_num_threads=2;opt.inter_op_num_threads=1
16
+ session=ort.InferenceSession(model_path,sess_options=opt,providers=["CPUExecutionProvider"])
17
+ input_names={v.name for v in session.get_inputs()}
18
+ scores=[];started=time.monotonic()
19
+ for offset in range(0,len(pairs),32):
20
+ batch=pairs[offset:offset+32]
21
+ texts=[s for row in batch for s in [row["source_text"],row["target_text"]]]
22
+ enc=tok.encode_batch(texts)
23
+ inputs={"input_ids":np.asarray([x.ids for x in enc],dtype=np.int64),"attention_mask":np.asarray([x.attention_mask for x in enc],dtype=np.int64),"token_type_ids":np.asarray([x.type_ids for x in enc],dtype=np.int64)}
24
+ output=session.run(None,{k:v for k,v in inputs.items() if k in input_names})[0]
25
+ if output.ndim==3:
26
+ mask=inputs["attention_mask"][...,None]
27
+ vectors=(output*mask).sum(1)/mask.sum(1).clip(1)
28
+ else:vectors=output
29
+ vectors=vectors/np.linalg.norm(vectors,axis=1,keepdims=True).clip(1e-9)
30
+ scores.extend(float(np.dot(vectors[i],vectors[i+1])) for i in range(0,len(vectors),2))
31
+ if offset%256==0:
32
+ progress={"done":len(scores),"total":len(pairs),"seconds":round(time.monotonic()-started,1)}
33
+ (D/"alignment_progress.json").write_text(json.dumps(progress));print("CPU_ALIGNMENT",json.dumps(progress),flush=True)
34
+ assert len(scores)==len(pairs) and all(np.isfinite(scores))
35
+ (D/"alignment_scores.json").write_text(json.dumps(scores))
36
+ meta={"model":repo,"revision":revision,"runtime":"ONNX Runtime CPU, portable AVX2 UINT8","file":"onnx/model_quint8_avx2.onnx","max_tokens":128,"records":len(pairs),"elapsed_seconds":time.monotonic()-started}
37
+ (D/"alignment_metadata.json").write_text(json.dumps(meta,indent=2))
38
+ print(json.dumps(meta,indent=2))
translation_manifest.json CHANGED
@@ -1,49 +1,12 @@
1
  {
2
- "name": "AstheralDataset",
3
- "version": "1.0",
4
- "total_examples": 5000,
5
- "unique_example_ids": 5000,
6
- "unique_normalized_text_values": 10000,
7
- "split_counts": {
8
- "train": 4500,
9
- "validation": 250,
10
- "test": 250
11
  },
12
- "language_counts": {
13
- "train": {
14
- "de": 900,
15
- "fr": 900,
16
- "es": 900,
17
- "it": 900,
18
- "pt": 900
19
- },
20
- "validation": {
21
- "de": 50,
22
- "fr": 50,
23
- "es": 50,
24
- "it": 50,
25
- "pt": 50
26
- },
27
- "test": {
28
- "de": 50,
29
- "fr": 50,
30
- "es": 50,
31
- "it": 50,
32
- "pt": 50
33
- }
34
- },
35
- "source_dataset": "Helsinki-NLP/opus-100",
36
- "source_revision": "805090dc28bf78897da9641cdf08b61287580df9",
37
- "normalization": "Unicode NFKC, casefold, punctuation removed, whitespace collapsed",
38
- "deduplication": "Global source/target text uniqueness across all languages and splits; identical source-target pairs excluded",
39
- "rejected": {
40
- "duplicate_or_identical_text": 66,
41
- "length": 1939,
42
- "non_sentence_content": 42
43
- },
44
- "file_sha256": {
45
- "train.parquet": "db2ccfff2cb499647cd134bdbf03840b9d72c98ccbadf5af25572a189cb2bcc5",
46
- "validation.parquet": "7e65a4bc923eadaafa3cf92b8af54aeadb1aafdd2265547c52be078f6131db55",
47
- "test.parquet": "ef098abdabd64007cb91451f25e9d452f076b897bc11ce464fc9157b7b8fffa3"
48
- }
49
  }
 
1
  {
2
+ "pairs": 2065,
3
+ "languages": {
4
+ "it": 437,
5
+ "es": 447,
6
+ "de": 343,
7
+ "pt": 429,
8
+ "fr": 409
 
 
9
  },
10
+ "quality_report": "quality_report.json",
11
+ "source_revision": "8a36f2f8aa9f6cb2a64086f2b9de9f8327da32fd"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
  }