{"id":48844169,"url":"https://github.com/impresso/fair-sentence-transformers","last_synced_at":"2026-04-15T04:02:07.378Z","repository":{"id":320891520,"uuid":"974962245","full_name":"impresso/fair-sentence-transformers","owner":"impresso","description":"Positionally fairer SentenceTransformers. Replication Code for preprint \"Information Representation Fairness in Long-Document Embeddings: The Peculiar Interaction of Positional and Language Bias\". All resources are publicly available and open-source, hoping to facilitate further research in Information Representation Fairness.","archived":false,"fork":false,"pushed_at":"2026-04-01T09:28:39.000Z","size":12839,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-04-01T11:35:48.935Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"agpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/impresso.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-04-29T15:08:23.000Z","updated_at":"2026-04-01T09:28:43.000Z","dependencies_parsed_at":"2025-10-26T16:17:36.136Z","dependency_job_id":"ddc73185-836c-4415-baf8-e16fce4e88f3","html_url":"https://github.com/impresso/fair-sentence-transformers","commit_stats":null,"previous_names":["e-schuh/locobench"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/impresso/fair-sentence-transformers","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/impresso%2Ffair-sentence-transformers","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/impresso%2Ffair-sentence-transformers/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/impresso%2Ffair-sentence-transformers/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/impresso%2Ffair-sentence-transformers/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/impresso","download_url":"https://codeload.github.com/impresso/fair-sentence-transformers/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/impresso%2Ffair-sentence-transformers/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31825515,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-14T18:05:02.291Z","status":"online","status_checked_at":"2026-04-15T02:00:06.175Z","response_time":63,"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":"2026-04-15T04:02:06.351Z","updated_at":"2026-04-15T04:02:07.370Z","avatar_url":"https://github.com/impresso.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# [Information Representation Fairness in Long-Document Embeddings: The Peculiar Interaction of Positional and Language Bias](https://arxiv.org/abs/2601.16934) - FairSentenceTransformers and Replication ![License: AGPLV3+](https://img.shields.io/badge/License-AGPLV3+-brightgreen.svg) \n\n---\n\n## Overview\n\nThis repository accompanies our [preprint(under review)](https://arxiv.org/abs/2601.16934) with source code for the examination of positional bias in long documents of multilingual embedding models and the fair-sentence-transformers extension.\n\n---\n\n## Table of Contents\n\n- [Overview](#overview)\n- [Fair Sentence Transformers](#fair-sentence-transformers)\n- [Datasets](#datasets)\n- [Repository Structure](#repository-structure)\n- [Reproducing the Experiments](#reproducing-the-experiments)\n- [Citation](#citation)\n- [About Impresso](#about-impresso)\n- [License](#license)\n\n---\n\n## Fair Sentence Transformers\n\nWe introduce an inference-time attention calibration method, implemented as an extension of Sentence Transformers called Fair Sentence Transformers. This tool aims to:\n\n1. Provide a Wrapper Class for inference-time calibration techniques that improve fairness in embedding models.\n2. Support existing and future embedding model releases through generic implementations configurable to each model's attributes.\n\n# Datasets\n\nWe provide a multilingual comparable Wikipedia dataset for examining positional bias (see Section 3). The dataset includes six languages: English, Hindi, German, Italian, Korean, and Chinese.\n\nAccess the dataset: https://huggingface.co/datasets/impresso-project/wiki_comparable_corpus_en_de_hi_it_ko_zh\nFor instructions on loading and using the dataset, refer to the README on Hugging Face.\n\n### Setup and Example use:\n\n```bash\npoetry install\n```\n\n```python\nfrom src.fair_sentence_transformers.core.fair_sentence_transformer import FairSentenceTransformer\n \ninput_texts = [\n    \"What is the capital of Switzerland?\",\n    \"How to make an omelette?\",\n    \"Wie viele Einwohner hat Deutschland?\",\n]\n \nmodel_name_or_path = \"Alibaba-NLP/gte-multilingual-base\"\nmodel = FairSentenceTransformer(model_name_or_path)\n \n# Standard SentenceTransformer embeddings\nembeddings = model.encode(input_texts)  # shape: (3, 768)\n \n# Fair SentenceTransformer embeddings\nfair_embeddings = model.encode_positionally_fair(\n    input_texts,\n    calib_strength=0.5,\n    calib_basket_size=128,\n    calib_layers=6,\n)  # shape: (3, 768)\n```\npip install coming soon\n\n### Supported Models and Methods\n\n**encode_positionally_fair** - Inference-time attention calibration to ensure fair representation of input from all positions.\n\n**Tested Models:**\n- [Alibaba-NLP/gte-multilingual-base](https://huggingface.co/Alibaba-NLP/gte-multilingual-base)\n- [BAAI/bge-m3](https://huggingface.co/BAAI/bge-m3)\n- [ibm-granite/granite-embedding-278m-multilingual](https://huggingface.co/ibm-granite/granite-embedding-278m-multilingual), [107M version](ibm-granite/granite-embedding-107m-multilingual)\n- Qwen3-Embedding Family: [0.6B](https://huggingface.co/Qwen/Qwen3-Embedding-0.6B), [4B](https://huggingface.co/Qwen/Qwen3-Embedding-4B), [8B](https://huggingface.co/Qwen/Qwen3-Embedding-8B)\n- microsoft/harrier-oss-v1: [0.6B](https://huggingface.co/microsoft/harrier-oss-v1-0.6b), 270M(WIP), 27B(WIP)\n\n**Extensibility:** Our implementation can support additional models with a small configuration and quick test of new additions. Feel free put a pull request to add support to your favourite model or simply reach out to andrianos.michail@cl.uzh.ch\n\n---\n\n## Reproducing the Experiments\n\nTo fully replicate our results, please follow the instructions decipited in our Replication readme (REPL_README.md)\n\n## Citation\n\nIf you use these resources, please cite our preprint:\n\n```bibtex\n@misc{schuhmacher2026informationrepresentationfairnesslongdocument,\n      title={Information Representation Fairness in Long-Document Embeddings: The Peculiar Interaction of Positional and Language Bias}, \n      author={Elias Schuhmacher and Andrianos Michail and Juri Opitz and Rico Sennrich and Simon Clematide},\n      year={2026},\n      eprint={2601.16934},\n      archivePrefix={arXiv},\n      primaryClass={cs.CL},\n      url={https://arxiv.org/abs/2601.16934}, \n}\n```\n\n## About Impresso\n\n### Impresso project\n\n[Impresso - Media Monitoring of the Past](https://impresso-project.ch) is an interdisciplinary research project that aims to develop and consolidate tools for processing and exploring large collections of media archives across modalities, time, languages and national borders. The first project (2017-2021) was funded by the Swiss National Science Foundation under grant No. [CRSII5_173719](http://p3.snf.ch/project-173719) and the second project (2023-2027) by the SNSF under grant No. [CRSII5_213585](https://data.snf.ch/grants/grant/213585) and the Luxembourg National Research Fund under grant No. 17498891.\n\n### Copyright\n\nCopyright (C) 2026 The Impresso team.\n\n### License\n\nThis program is provided as open source under the [GNU Affero General Public License](https://github.com/impresso/impresso-pyindexation/blob/master/LICENSE) v3 or later.\n\n---\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"https://github.com/impresso/impresso.github.io/blob/master/assets/images/3x1--Yellow-Impresso-Black-on-White--transparent.png?raw=true\" width=\"350\" alt=\"Impresso Project Logo\"/\u003e\n\u003c/p\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fimpresso%2Ffair-sentence-transformers","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fimpresso%2Ffair-sentence-transformers","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fimpresso%2Ffair-sentence-transformers/lists"}