MCPcopy
hub / github.com/riffusion/riffusion-hobby / embed_text

Method embed_text

riffusion/riffusion_pipeline.py:166–179  ·  view source on GitHub ↗

Takes in text and turns it into text embeddings.

(self, text)

Source from the content-addressed store, hash-verified

164
165 @functools.lru_cache()
166 def embed_text(self, text) -> torch.FloatTensor:
167 """
168 Takes in text and turns it into text embeddings.
169 """
170 text_input = self.tokenizer(
171 text,
172 padding="max_length",
173 max_length=self.tokenizer.model_max_length,
174 truncation=True,
175 return_tensors="pt",
176 )
177 with torch.no_grad():
178 embed = self.text_encoder(text_input.input_ids.to(self.device))[0]
179 return embed
180
181 @functools.lru_cache()
182 def embed_text_weighted(self, text) -> torch.FloatTensor:

Callers 1

riffuseMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected