Live data from Hacker News

Shapeshift: Semantically map JSON objects using key-level vector embeddings

github.com

1–10 of 37 posts

Re: Shapeshift: Semantically map JSON objects using key-level vector embeddings

#2
Maybe I'm not the target audience, but here are simple questions to the author or potential users:

What about anything more complex like date of birth to age or the other way round? Also since we will inevitably incur costs, why not let a llm write a transformation rule for us?

Re: Shapeshift: Semantically map JSON objects using key-level vector embeddings

#4
post #3

What is this for? The examples given could be handled deterministically. Is this for situations where you don't know JSON schemas in advance? What situations are those?

The lazy part of my brain screams “use this instead of dealing properly with nested objects!” In a production setting I’d be worried about consistency from the base to result layers if based on LLM transpositioning.

Re: Shapeshift: Semantically map JSON objects using key-level vector embeddings

#5

Maybe I'm not the target audience, but here are simple questions to the author or potential users: What about anything more complex like date of birth to age or the other way round? Also since we will inevitably incur costs, why not let a llm write a transformation rule for us?

My thinking as well.

Re: Shapeshift: Semantically map JSON objects using key-level vector embeddings

#7
post #3

What is this for? The examples given could be handled deterministically. Is this for situations where you don't know JSON schemas in advance? What situations are those?

As is, it's not good for much beyond looking cool. (Maybe implementing Postel's Law for a json API, but I think that's considered bad taste these days.)

If instead of transforming a single object it would output a table of src_field->dst_field, it could potentially be a useful first pass in some ETL development.

Re: Shapeshift: Semantically map JSON objects using key-level vector embeddings

#9
This is the code that does the work: https://github.com/rectanglehq/Shapeshift/blob/d954dab2a866c...

There are a few ways this could be made a less expensive to run:

1. Cache those embeddings somewhere. You're only embedding simple strings like "name" and "address" - no need to do that work more than once in an entire lifetime of running the tool.

2. As suggested here https://news.ycombinator.com/item?id=40973028 change the design of the tool so instead of doing the work it returns a reusable data structure mapping input keys to output keys, so you only have to run it once and can then use that generated data structure to apply the transformations on large amounts of data in the future.

3. Since so many of the keys are going to have predictable names ("name", "address" etc) you could even pre-calculate embeddings for the 1,000 most common keys across all three embedding providers and ship those as part of the package.

Also: in https://github.com/rectanglehq/Shapeshift/blob/d954dab2a866c... you're using Promise.map() to run multiple embeddings through the OpenAI API at once, which risks tripping their rate-limit. You should be able to pass the text as an array in a single call instead, something like this:

        const response = await this.openai!.embeddings.create({
          model: this.embeddingModel,
          input: texts,
          encoding_format: "float",
        });
        return response.data.map(item => item.embedding);
https://platform.openai.com/docs/api-reference/embeddings/cr... says input can be a string OR an array - that's reflected in the TypeScript library here too: https://github.com/openai/openai-node/blob/5873a017f0f2040ef...

Re: Shapeshift: Semantically map JSON objects using key-level vector embeddings

#10
post #9

This is the code that does the work: https://github.com/rectanglehq/Shapeshift/blob/d954dab2a866c... There are a few ways this could be made a less expensive to run: 1. Cache those embeddings somewhere. You're only embedding simple strings like "name" and "address" - no need to do that work more than once in an entire lifetime of running the tool. 2. As suggested here https://news.ycombinator.com/item?id=40973028 cha…

Thanks for the suggestions! Will implement these. Caching is a great idea.
Post reply on HN