4 ms·
I'd like to find a way to start with an embedding and have the computer generate some text that corresponds, at least approximately. There are tools that do tha
by sp332 3y ago
I'd like to find a way to start with an embedding and have the computer generate some text that corresponds, at least approximately. There are tools that do that for images, right? Like Stable Diffusion, you can put an image in, get an embedding, then do gradient descent in latent space to find a new embedding, then generate a new image from that.
- kreeben 3y agoThe most basic of embedding (that I can think of) is one where the number of dimensions corresponds to the number of unique characters in your lexicon. If there is a number in one of the components of your embedding that is greater than "0", then you know what characters they are. This embedding does not encode the order of the characters, though. They are just a "bag of characters". If you were to then also encode the order of the characters in, say, yet another embedding, you could use those two embeddings to recreate the original word. Combine the two embeddings into a new vector space and BAM, you've invented "embedding2word".
- jorlow 3y agoGpt (and many others) just add these embeddings together in the model, so you could do that and have one vector that encodes both things together
- TeMPOraL 3y agoThat seems suboptimal, for the same reason LLMs are trained on tokens, and not characters. Tokens seem like a much better "unit of meaning" than characters. Curiously, this also applies to humans: we learn words first, spelling later; we almost always think in terms of words, subwords and phrases, and we're really fast at it - while anything to do with spelling seems to demand much more focus, and some degree of conscious hand-holding. As for encoding sequence, I'm curious how that happens and need to find relevant papers, but I imagine there might be some "n-gram dimensions" in the vector, as in one value for "I'm a first token in a sequence", one value for "I'm a second token in a sequence", etc., which would encode the "occurs before"/"occurs after" relationships using few dimensions, leaving the rest for more interesting relationships.
- freeone3000 3y agoYou can get this fairly trivially with word and sentence embeddings just by running the inverse (huggingface models have this as a builtin). For llama, the same is possible, but the matrix transpose is your responsibility :)
- sp332 3y agoOk, I got annoyed at oobabooga (around when it first came out) and have been messing with llama.cpp since then. I can't tell if this feature request is the same thing we're talking about here? https://github.com/ggerganov/llama.cpp/issues/1552 https://github.com/ggerganov/llama.cpp/issues/1552 I guess if I want more features, I should move on to something that has more features lol.
- TeMPOraL 3y agoLooking at that issue, I wonder how is it that everyone seemed to not understand the poster's question? The feature itself is something I wanted to play with too, as it's kind of an obvious thing to want. I mean, these models execute a pipeline: [text] -> [tokens] -> {[embeddings] -> [inference] -> [embeddings]} -> [tokens] -> [text] Where the part in { ... } may or may not be implemented as a single step (i.e. all three parts interleaved). Now, apparently all the magic[0] of transformer models sits in the latent space and is invoked by the { ... } bit. We also know for sure that you can make the pipeline look like this: [text] -> [tokens] -> {[embeddings] -> [inference]} -> [embeddings] So with the two things in mind, it's kind of obvious you'd also want a pipe that looks like: [embeddings] -> [inference] -> [embeddings] (and optionally -> [tokens] -> [text]) for the sole purpose of messing around and exploring the latent space itself. I'm very much not up to date with the whole space, so I might be missing something, but I'd thought that poking around the latent space would be getting a lot more attention than it seems to be getting. (EDIT: replaced < ... > with { ... } for readability.) -- [0] Not the "how do transformers tick" details, but the "how the hell are they this good" / "GPT-4 is uncanny valley" / "could this thing be actually thinking?" kind of magic.
- deleted 3y ago[deleted]
- microtonal 3y agoThis is basically how RNN encoder/decoder architectures worked. The encoder encoded the input as a single vector and the decoder would decode this into text (eg. for machine translation) [1]. However, fixed-length vectors generally required too much 'compression' to represent variable-length text, so people started adding attention mechanisms so that the decoder could also attend to the input text. And the seminal Transformer paper by Vaswani and others showed that you only need an attention mechanism and you could ditch the RNN (hence the title 'Attention is all you need') and here we are. So, this has been possible already for quite a long time. [1] https://arxiv.org/pdf/1409.3215.pdf https://arxiv.org/pdf/1409.3215.pdf
- sdenton4 3y agoTo be sure, the seq2seq style already allowed multi length embeddings before transformers were a thing. RNN vs Transformer is entirely an implementation choice; you can build a seq2seq model with any combination of transformer, RNN, and conventional layers. Each of these layer types have different computational costs for training and inference, and encode different inductive biases, which may be more or less appropriate to a given problem.
- bryan0 3y agoFor some models, perhaps you can use get_output_embeddings() like in this example: https://stackoverflow.com/a/65267429 https://stackoverflow.com/a/65267429