Run this model with HF Jobs
Run jfkback/hypencoder.2_layer on Hugging Face's managed compute, monitor its progress, and retrieve the results when it's done.
Paste one of these prompts into your coding agent:
Fine-tune on my dataset
Use HF Jobs to fine-tune https://huggingface.co/jfkback/hypencoder.2_layer. Ask me which dataset to train on, then push the fine-tuned model to a new model repo. Run `hf jobs --help` first to learn the CLI.
Run batch inference
Use HF Jobs to run batch inference with https://huggingface.co/jfkback/hypencoder.2_layer on the inputs in a mounted HF Bucket. Ask me which Bucket to use, then write the outputs back to it and keep each input ID. Run `hf jobs --help` first to learn the CLI.
Instructions to use jfkback/hypencoder.2_layer with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use jfkback/hypencoder.2_layer with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("feature-extraction", model="jfkback/hypencoder.2_layer")# pip install -U transformers accelerate # Load model directly from transformers import HypencoderDualEncoder model = HypencoderDualEncoder.from_pretrained("jfkback/hypencoder.2_layer", device_map="auto") - Notebooks
- Google Colab
- Kaggle
Add pipeline tag and license
#1
by nielsr HF Staff - opened
12345678910111213141516171819205 unmodified lines262728293031---library_name: transformersdatasets:- microsoft/ms_marcolanguage:- enbase_model:- google-bert/bert-base-uncased---# Model CardThis is the official model from the paper [Hypencoder: Hypernetworks for Information Retrieval](https://arxiv.org/abs/2502.05364).## Model DetailsThis is a Hypencoder Dual Enocder. It contains two trunks the text encoder and Hypencoder. The text encoder converts items into 768 dimension vectors while the Hypencoder converts text into a small neural network which takes the 768 dimension vector from the text encoder as input. This small network is then used to output a relevance score. To use this model please take a look at the [Github](https://github.com/jfkback/hypencoder-paper) page which contains the required code and details on how to run the model.### Model VariantsWe released the four models used in the paper. Each model is identical except the small neural networks, which we refer to as q-nets, have different numbers of hidden layers.5 unmodified lines| [jfkback/hypencoder.6_layer](https://huggingface.co/jfkback/hypencoder.6_layer) | 6 || [jfkback/hypencoder.8_layer](https://huggingface.co/jfkback/hypencoder.8_layer) | 8 |## Citation**BibTeX:**```12345678910111213141516171819205 unmodified lines262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182---base_model:- google-bert/bert-base-uncaseddatasets:- microsoft/ms_marcolanguage:- enlibrary_name: transformerslicense: apache-2.0pipeline_tag: feature-extraction---# Model CardThis is the official model from the paper [Hypencoder: Hypernetworks for Information Retrieval](https://arxiv.org/abs/2502.05364).## Model DetailsThis is a Hypencoder Dual Encoder. It contains two trunks the text encoder and Hypencoder. The text encoder converts items into 768 dimension vectors while the Hypencoder converts text into a small neural network which takes the 768 dimension vector from the text encoder as input. This small network is then used to output a relevance score. To use this model please take a look at the [Github](https://github.com/jfkback/hypencoder-paper) page which contains the required code and details on how to run the model.### Model VariantsWe released the four models used in the paper. Each model is identical except the small neural networks, which we refer to as q-nets, have different numbers of hidden layers.5 unmodified lines| [jfkback/hypencoder.6_layer](https://huggingface.co/jfkback/hypencoder.6_layer) | 6 || [jfkback/hypencoder.8_layer](https://huggingface.co/jfkback/hypencoder.8_layer) | 8 |## Quick Start#### Using the pretrained Hypencoders as stand-alone models```pythonfrom hypencoder_cb.modeling.hypencoder import Hypencoder, HypencoderDualEncoder, TextEncoderfrom transformers import AutoTokenizerdual_encoder = HypencoderDualEncoder.from_pretrained("jfkback/hypencoder.6_layer")tokenizer = AutoTokenizer.from_pretrained("jfkback/hypencoder.6_layer")query_encoder: Hypencoder = dual_encoder.query_encoderpassage_encoder: TextEncoder = dual_encoder.passage_encoderqueries = ["how many states are there in india","when do concussion symptoms appear",]passages = ["India has 28 states and 8 union territories.","Concussion symptoms can appear immediately or up to 72 hours after the injury.",]query_inputs = tokenizer(queries, return_tensors="pt", padding=True, truncation=True)passage_inputs = tokenizer(passages, return_tensors="pt", padding=True, truncation=True)q_nets = query_encoder(input_ids=query_inputs["input_ids"], attention_mask=query_inputs["attention_mask"]).representationpassage_embeddings = passage_encoder(input_ids=passage_inputs["input_ids"], attention_mask=passage_inputs["attention_mask"]).representation# The passage_embeddings has shape (2, 768), but the q_nets expect the shape# (num_queries, num_items_per_query, input_hidden_size) so we need to reshape# the passage_embeddings.# In the simple case where each q_net only takes one passage, we can just# reshape the passage_embeddings to (num_queries, 1, input_hidden_size).passage_embeddings_single = passage_embeddings.unsqueeze(1)scores = q_nets(passage_embeddings_single) # Shape (2, 1, 1)# [# [[-12.1192]],# [[-13.5832]]# ]# In the case where each q_net takes both passages we can reshape the# passage_embeddings to (num_queries, 2, input_hidden_size).passage_embeddings_double = passage_embeddings.repeat(2, 1).reshape(2, 2, -1)scores = q_nets(passage_embeddings_double) # Shape (2, 2, 1)# [# [[-12.1192], [-32.7046]],# [[-34.0934], [-13.5832]]# ]```## Citation**BibTeX:**```
README.md+57-6