{"id":21006232,"url":"https://github.com/derlin/swisstext-bert-lid","last_synced_at":"2026-07-02T09:31:12.394Z","repository":{"id":151664456,"uuid":"240495137","full_name":"derlin/swisstext-bert-lid","owner":"derlin","description":"Package to finetune and use a BERT model for Swiss-German language identification.","archived":false,"fork":false,"pushed_at":"2020-02-16T18:13:39.000Z","size":20,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-11-10T07:33:13.670Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/derlin.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-02-14T11:39:14.000Z","updated_at":"2024-06-22T02:46:04.000Z","dependencies_parsed_at":null,"dependency_job_id":"6275ce94-a7cf-419e-82bd-7c4958826596","html_url":"https://github.com/derlin/swisstext-bert-lid","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/derlin/swisstext-bert-lid","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/derlin%2Fswisstext-bert-lid","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/derlin%2Fswisstext-bert-lid/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/derlin%2Fswisstext-bert-lid/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/derlin%2Fswisstext-bert-lid/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/derlin","download_url":"https://codeload.github.com/derlin/swisstext-bert-lid/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/derlin%2Fswisstext-bert-lid/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":35041996,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-07-02T02:00:06.368Z","response_time":173,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-19T08:50:01.043Z","updated_at":"2026-07-02T09:31:12.370Z","avatar_url":"https://github.com/derlin.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Swiss-German LID using BERT\n\nThis repository let's you finetune a BERT model to perform the task of Language Identification.\nThe target task is to properly identify Swiss German. \n\nThe languages the model will be trained on are:\n\n* `afr`: Afrikaans\n* `deu`: German\n* `gsw`: Swiss German\n* `gsw_like`: a mix of Bavarian, Kolsch, Limburgan, Low German, Northern Frisian and Palatine German\n* `ltz`: Luxembourgian\n* `nld`: Dutch\n* `other`: a mix of Catalan, Croatian, Danish, Esperanto, Estonian, Finnish, French, Irish, Galician,\nIcelandic, Italian, Javanese, Konkani, Papiamento, Portuguese, Romanian, Slovenian, Spanish, Swahili and Swedish\n\nThe procedure:\n\n1. ensure you have a pip version \u003e= 15.0: `pip install --upgrade pip`\n2. install this repo:  `pip install .` (or `pip install -e .`, for editable mode). **DO NOT USE setup.py directly**;\n3. get Swiss German sentences into a CSV file;\n4. use the scripts in `training` to generate a model (see below);\n5. set the generated model as a default in the module `bert_lid`, by copying the out directory to `bert_lid/models/default`;\n   (Note: if you didn't install the module in development mode, the model must be written to the location of the installed module);\n6. now, you can use `bert_lid.BertLid` and install it in other environments;\n\n## Training a model\n\n\u003cp style=\"background-color: #FF000055\"\u003e\n**Important notice** we provide everything needed to train the model, **except the Swiss-German** data.\nIt is your task to generate one CSV file containing Swiss German sentences in a column named `text`.\nTip: you can access Swiss German sentences from the Leipzig Corpora Collection.\n\u003c/p\u003e\n\nOnce you have a Swiss German CSV file ready, the only thing left to do is to run the scripts in the `training` folder in order.\n\n```bash\n# ensure you launch the scripts from the training directory !\ncd training\n\n./1_download-data.py \n./2_prepare-data.py --gsw path/to/swiss-german-sentences.csv\n./3_split-data.py\n./4_finetune-bert.sh  # \u003c= this one long-running (\u003e20 minutes), would better be running in a screen\n./4_eval-model.py\n```\n\nAt this point, you should have a model saved in `training/out`. The only thing left to do is to make it the default model,\nby copying it to `bert_lid/models/default` (actual location varies depending on the kind of installation you did, install or development):\n\n```bash\nbert_lid_install_model -i training/out\n```\n\n## Inference\n\nAs long as you have a model somewhere (or installed one as the default using script 6 in `training`), this is straight-forward:\n\n```python\n\u003e\u003e\u003e from bert_lid import BertLid\n\u003e\u003e\u003e lid = BertLid()\n\u003e\u003e\u003e lid.predict(['Das isch sone seich'])\n(['gsw'], [99.83619689941406])\n\u003e\u003e\u003e lid.predict(['Trop top ce module, il marche bien et est bien documenté!'], mode='row')\n[('Trop top ce module, il marche bien et est bien documenté!', 'other', 99.75711822509766)]\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fderlin%2Fswisstext-bert-lid","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fderlin%2Fswisstext-bert-lid","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fderlin%2Fswisstext-bert-lid/lists"}