Views
No views yet
environment.yaml (optional)conda env create -f environment.yaml1git clone https://github.com/hieum98/lusifer.git
2cd lusifer
3pip install -e .1pip install packaging
2pip install ninja
3pip install flash-attn --no-build-isolationfrom_pretrained method. The model can be loaded from the Hugging Face model hub by providing the model name or path to the model weights. The following code snippet demonstrates how to load the model from the Hugging Face model hub.1from lusifer.models.lusifer import Lusifer
2
3model = Lusifer.from_pretrained("Hieuman/LUSIFER")str or List[str]. The model also can receive instruction alongside the sentence.1import torch
2from lusifer.models.lusifer import Lusifer
3
4model = Lusifer.from_pretrained("Hieuman/LUSIFER")
5
6model = model.to("cuda")
7
8# Encoding queries using instructions
9instruction = "Given a web search query, retrieve relevant passages that answer the query:"
10queries = [
11 "how much protein should a female eat",
12 "summit define",
13]
14q_reps = model.encode(sentences=queries)
15
16# Encoding documents. Instruction are not required for documents
17documents = [
18 "As a general guideline, the CDC's average requirement of protein for women ages 19 to 70 is 46 grams per day. But, as you can see from this chart, you'll need to increase that if you're expecting or training for a marathon. Check out the chart below to see how much protein you should be eating each day.",
19 "Definition of summit for English Language Learners. : 1 the highest point of a mountain : the top of a mountain. : 2 the highest level. : 3 a meeting or series of meetings between the leaders of two or more governments.",
20]
21d_reps = model.encode(sentences=documents)
22
23# Compute cosine similarity
24q_reps_norm = torch.nn.functional.normalize(torch.from_numpy(q_reps), p=2, dim=1)
25d_reps_norm = torch.nn.functional.normalize(torch.from_numpy(d_reps), p=2, dim=1)
26cos_sim = torch.mm(q_reps_norm, d_reps_norm.transpose(0, 1))
27
28print(cos_sim)1python -m src.main \
2 --config_file scripts/configs/aligment_training_reconstruction_and_completion.yaml \
3 --nodes 1 \
4 --devices 4 scripts/configs/aligment_training_reconstruction_and_completion.yaml file. For more details about the configuration file, please refer to the scripts/configs/aligment_training_reconstruction_and_completion.yaml file and the arguments in the lusifer/args.py file.scripts/configs/alignment_training_reconstruction.yaml file. We suggest using the reconstruction task only first to stabilize the training process before adding the completion task.1python -m src.main \
2 --config_file scripts/configs/representation_fintuning_retrieval_data_only.yaml \
3 --nodes 1 \
4 --devices 4 scripts/configs/representation_finetuning_all.yaml file. We suggest using the retrieval data only first to stabilize the training process before adding the non-retrieval data.mteb library. To evaluate the model, run the following command:1python -m lusifer.eval.eval \
2 --model_name_or_path Hieuman/LUSIFER \
3 --is_lusifer \1@misc{man2025lusiferlanguageuniversalspace,
2 title={LUSIFER: Language Universal Space Integration for Enhanced Multilingual Embeddings with Large Language Models},
3 author={Hieu Man and Nghia Trung Ngo and Viet Dac Lai and Ryan A. Rossi and Franck Dernoncourt and Thien Huu Nguyen},
4 year={2025},
5 eprint={2501.00874},
6 archivePrefix={arXiv},
7 primaryClass={cs.CL},
8 url={https://arxiv.org/abs/2501.00874},
9}