daft.functions.embed_text#
embed_text #
embed_text(text: Expression, *, provider: str | Provider | None = None, model: str | None = None, dimensions: int | None = None, **options: Unpack[EmbedTextOptions]) -> Expression
Returns an expression that embeds text using the specified embedding model and provider.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text | String Expression | The input text column expression. | required |
provider | str | Provider | None | The provider to use for the embedding model. If None, the default provider is used. | None |
model | str | None | The embedding model to use. Can be a model instance or a model name. If None, the default model is used. | None |
dimensions | int | None | Number of dimensions the output embeddings should have, if the provider and model support specifying. If None, will use the default for the model. | None |
**options | Unpack[EmbedTextOptions] | Any additional options to pass for the model. | {} |
Note
Make sure the required provider packages are installed (e.g. vllm, transformers, openai).
Returns:
| Name | Type | Description |
|---|---|---|
Expression | Embedding Expression | An expression representing the embedded text vectors. |
Examples:
1 2 3 4 5 6 7 8 9 10 11 12 13 | |
╭────────────────────────────────┬────────────────────────────────┬───────────────────┬──────────────────────────╮
│ text ┆ meta ┆ red_pajama_subset ┆ embeddings │
│ --- ┆ --- ┆ --- ┆ --- │
│ String ┆ String ┆ String ┆ Embedding[Float32; 384] │
╞════════════════════════════════╪════════════════════════════════╪═══════════════════╪══════════════════════════╡
│ Григорианският календар (поня… ┆ {'title': 'Григориански кален… ┆ wikipedia ┆ ▃▆█▆▆▆█▇▆▅▃▆▆▅▅▆▅▅▂▂▇▇▄▁ │
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
│ GNU General Public License (н… ┆ {'title': 'GNU General Public… ┆ wikipedia ┆ ▆▁▇█▄▅▄▅▄▄▁▆▃▅▂▃▆▃▄▃█▆▇▅ │
├╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┼╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌╌┤
│ Лицензът за свободна документ… ┆ {'title': 'Лиценз за свободна… ┆ wikipedia ┆ ▄▆██▇▇▇█▇▆▂▇▄▁▅▃▇▇▃▃▆▆▅▂ │
╰────────────────────────────────┴────────────────────────────────┴───────────────────┴──────────────────────────╯
(Showing first 3 of 3 rows) Source code in daft/functions/ai/__init__.py
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 | |