Загрузка видео...

Не удалось загрузить видео

На главную

One magical part of Cursor’s internal tech stack is a prompt compilation library called priompt ( Here's why works so well... (1/12)

152,112 просмотров • 2 лет назад •via X (Twitter)

Комментарии: 12

Фото профиля Aman Sanger
Aman Sanger2 лет назад

Standard prompting libraries use variants of “f-strings” with subbed-in inputs. For us, a prompt is defined as a function that maps some set of inputs X and a token budget n to some string, s: p(X, n) = s We call this operation "rendering" (2/12)

Фото профиля Aman Sanger
Aman Sanger2 лет назад

For example, my inputs, X, could include conversation history, contents of the current file, chunks of documentation, and codebase context we deem relevant. This sums to 100K tokens. But the budget we are working with may just be 4000 tokens. (3/12)

Фото профиля Aman Sanger
Aman Sanger2 лет назад

For some input, X_1, let's say the text around the user's cursor matters most. This is followed by the last message in the conversation history, then the first few chunks of both documentation and codebase context. (4/12)

Фото профиля Aman Sanger
Aman Sanger2 лет назад

Finally, every 5 lines of text above and below the selected region matters as much as each preceding message in the conversation history. From X_1, we must render the string that contains the most useful pieces of information, with prioritization in the order described (5/12)

Фото профиля Aman Sanger
Aman Sanger2 лет назад

We need a framework with enough flexibility to design these mappings, but enough abstraction that you won’t be writing a million if/else’s with tedious string manipulation. This is where priompt comes in - A JSX and priorities-based prompting library. (6/12)

Фото профиля Aman Sanger
Aman Sanger2 лет назад

Prompt design has many similarities to web design ( The notable ones are: 1. Dynamic views given variable inputs (or props) 2. Re-use of rendered primitives (component re-use) 3. Adaptive rendering given size constraint (screen width/token budget) (7/12)

Фото профиля Aman Sanger
Aman Sanger2 лет назад

What makes everything work are the “priorities” Each component has some priority, p, which is initially set via simple heuristics. When introducing embeddings/rerankers, components can be assigned priority equal to the deemed relevance. (8/12)

Фото профиля Aman Sanger
Aman Sanger2 лет назад

The promise of the priompt renderer is that it will find the smallest global priority, p*, such that when all components with p>p* are included, the total string is under the token budget. (9/12)

Фото профиля Aman Sanger
Aman Sanger2 лет назад

Consider this very simple toy prompt: It prioritizes later messages in the chat over older ones and will render as many messages as possible. Instead of cutting off the message that lies in the order, it chooses to not include it. (10/12)

Фото профиля Aman Sanger
Aman Sanger2 лет назад

But it gets an order of magnitude more expressive than this. A favorite of mine is the PriorityControlledCode, which powers most of our file-views. Both component composability and priorities dramatically improve quality and DX (11/12)

Фото профиля Aman Sanger
Aman Sanger2 лет назад

Combining these allows us to define expressive prompts with re-usable components with almost pixel-perfect context. This library was the brainchild of @arvid220, who had fantastic foresight into its usefulness

Фото профиля Aman Sanger
Aman Sanger2 лет назад

* @ArVID220u

Похожие видео