Delete README.md
Browse files
README.md
DELETED
|
@@ -1,74 +0,0 @@
|
|
| 1 |
-
# Parallel Corpus: Romansh - German
|
| 2 |
-
|
| 3 |
-
This repository contains the code and methodology used to create the Romansh–German parallel corpus published on [Hugging Face](https://huggingface.co/datasets/Sudehsna/parallel_dataset/settings). The project was developed as part of a programming course at the University of Zurich.
|
| 4 |
-
|
| 5 |
-
## Description
|
| 6 |
-
|
| 7 |
-
This project performs document-level alignment between Romansh and German web texts, which were extracted from the [Fineweb2](https://huggingface.co/datasets/HuggingFaceFW/fineweb-2) dataset. It uses [OpenAI](https://platform.openai.com/docs/models/text-embedding-3-small) embeddings and cosine similarity to identify potential parallel texts.
|
| 8 |
-
The full dataset is available on [Hugging Face](https://huggingface.co/datasets/Sudehsna/parallel_dataset/settings).
|
| 9 |
-
|
| 10 |
-
## Dataset
|
| 11 |
-
|
| 12 |
-
This project uses the Romansh and German partitions of the [Fineweb2](https://huggingface.co/datasets/HuggingFaceFW/fineweb-2) dataset. Both the original and the removed versions of the dataset were used to improve alignment coverage.
|
| 13 |
-
|
| 14 |
-
Since the German dataset contained significantly more entries than the Romansh dataset, it was filtered by retaining only those entries whose domains matched those found in the Romansh dataset.
|
| 15 |
-
|
| 16 |
-
## Method
|
| 17 |
-
|
| 18 |
-
1. **Preprocessing**:
|
| 19 |
-
- German dataset filtered to only contain domains also appearing in Romansh dataset
|
| 20 |
-
2. **Manual Evaluation**:
|
| 21 |
-
- A sample of 50 documents was manually checked to estimate alignability (see `analysis/manual_alignment`)
|
| 22 |
-
3. **Embedding**:
|
| 23 |
-
- Used [OpenAI](https://platform.openai.com/docs/models/text-embedding-3-small) `text-embedding-3-small` (with truncation at 8192 tokens)
|
| 24 |
-
4. **Similarity Calculation**:
|
| 25 |
-
- Cosine similarity computed between Romansh and German document embeddings
|
| 26 |
-
- With penalization for sentence length difference
|
| 27 |
-
5. **Evaluation**:
|
| 28 |
-
- A Negative gold standard was used to ensure quality: a set of Romansh documents known to have no valid German alignment.
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
## Getting Started
|
| 33 |
-
|
| 34 |
-
### Set up environment
|
| 35 |
-
```bash
|
| 36 |
-
python3 -m venv venv
|
| 37 |
-
source venv/bin/activate
|
| 38 |
-
pip install -r requirements.txt
|
| 39 |
-
```
|
| 40 |
-
|
| 41 |
-
### Run embedding
|
| 42 |
-
```bash
|
| 43 |
-
python3 scripts/get_embeddings.py
|
| 44 |
-
```
|
| 45 |
-
>**NOTE**: This project uses OpenAI's embedding models. To run the embedding script, you need to provide your own OpenAI API key.
|
| 46 |
-
|
| 47 |
-
The output is a `.csv` file with the following structure:
|
| 48 |
-
|
| 49 |
-
```
|
| 50 |
-
"text","id","metadata","embedding"
|
| 51 |
-
```
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
### Run similarity
|
| 55 |
-
```bash
|
| 56 |
-
python3 scripts/cosine_sim.py
|
| 57 |
-
```
|
| 58 |
-
|
| 59 |
-
The output is a `.jsonl` file containing entries in the following format:
|
| 60 |
-
|
| 61 |
-
```json
|
| 62 |
-
{
|
| 63 |
-
"romansh_text": " ... ",
|
| 64 |
-
"german_text": " ... ",
|
| 65 |
-
"similarity": float,
|
| 66 |
-
"original_similarity": float
|
| 67 |
-
}
|
| 68 |
-
```
|
| 69 |
-
To determine a suitable _similarity threshold_ for aligning sentence pairs, we tested multiple values and observed that a threshold of **?** provided the best balance for this dataset (refer to `./scripts/threshold_comparisons.py`).
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
## License
|
| 73 |
-
|
| 74 |
-
?
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|