Getting text embedding form Falcon model

I am currently using Falcon model (falcon 7b instruct). Its performance is quite satisfactory. But my question is that can we use this model somehow for creating the embedding of any text document like sentence transformers or text-embedding-ada from OpenAI?
Or this model is purely for text generation which means it cannot be used for text embedding purposes?

Thanks in advance


I am also looking into this. I tried the inference api method and the passed the input tokens directly both failed.

I was more interested to see the embeddings but i expect it will be extremely big … to even visualize with Colab

why it failed ? memory problem or function problem ?

Same issue here. I think it is a function/interface issue I am new to the library so it is possible I’m doing a tivial mistake but embedding-extraction does not seem to work using a “vanilla” approach.

model_name_falcon = "tiiuae/falcon-7b"

tokenizer_falcon = transformers.AutoTokenizer.from_pretrained(

tokenizer_falcon.pad_token = tokenizer_falcon.eos_token

model_falcon = transformers.pipeline(


just crashes

I am a bit unsure here but the issue may either be with the Falcon tokenizer pad/eos confusion or worse feature-extraction pipeline compatibility. As much as I know falcon does not output embedding directly or trained as a sentence transformer. A bypass I am trying now, is to follow the sequence classification pipeline and take the feature from the eos token instead of passing it to dense classifier layers.