-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
105 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package hello; | ||
|
||
|
||
import java.util.List; | ||
import java.util.Map; | ||
|
||
import cljs.source_map__init; | ||
import dev.langchain4j.data.segment.TextSegment; | ||
import dev.langchain4j.model.embedding.onnx.allminilml6v2.AllMiniLmL6V2EmbeddingModel; | ||
import dev.langchain4j.store.embedding.inmemory.InMemoryEmbeddingStore; | ||
import clojure.lang.Keyword; | ||
import clojure.lang.PersistentHashMap; | ||
|
||
public class Main { | ||
|
||
@SuppressWarnings("unchecked") | ||
public static Map<Keyword,Object> embedd(List<String> texts) { | ||
var model = new AllMiniLmL6V2EmbeddingModel(); | ||
var store = new InMemoryEmbeddingStore<TextSegment>(); | ||
|
||
for (String text : texts) { | ||
var ts = TextSegment.from(text); | ||
var embedding = model.embed(ts).content(); | ||
store.add(embedding, ts); | ||
|
||
} | ||
|
||
|
||
|
||
|
||
|
||
return PersistentHashMap.create( | ||
Keyword.intern("store") , store, | ||
Keyword.intern("model") , model, | ||
Keyword.intern("my-texts"),texts); | ||
|
||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
<packaging>jar</packaging> | ||
<groupId>llm</groupId> | ||
<artifactId>llm</artifactId> | ||
<version>0.1.0</version> | ||
<name>llm</name> | ||
<properties> | ||
<maven.compiler.source>21</maven.compiler.source> | ||
<maven.compiler.target>1.11</maven.compiler.target> | ||
</properties> | ||
|
||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>io.github.zmedelis</groupId> | ||
<artifactId>bosquet</artifactId> | ||
<version>2024.08.08</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.clojure</groupId> | ||
<artifactId>clojure</artifactId> | ||
<version>1.12.0</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>dev.langchain4j</groupId> | ||
<artifactId>langchain4j-embeddings-all-minilm-l6-v2</artifactId> | ||
<version>0.36.2</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>dev.langchain4j</groupId> | ||
<artifactId>langchain4j</artifactId> | ||
<version>0.36.2</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.scicloj</groupId> | ||
<artifactId>noj</artifactId> | ||
<version>2-beta2</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>cheshire</groupId> | ||
<artifactId>cheshire</artifactId> | ||
<version>5.13.0</version> | ||
</dependency> | ||
<dependency> | ||
<groupId>dev.langchain4j</groupId> | ||
<artifactId>langchain4j-open-ai</artifactId> | ||
<version>0.36.2</version> | ||
</dependency> | ||
</dependencies> | ||
<build> | ||
<sourceDirectory>java</sourceDirectory> | ||
</build> | ||
<repositories> | ||
<repository> | ||
<id>clojars</id> | ||
<url>https://repo.clojars.org/</url> | ||
</repository> | ||
</repositories> | ||
</project> |