Skip to content

Commit

Permalink
larger screen
Browse files Browse the repository at this point in the history
  • Loading branch information
behrica committed Dec 12, 2024
1 parent 70ba7ed commit a1d616b
Show file tree
Hide file tree
Showing 3 changed files with 105 additions and 0 deletions.
5 changes: 5 additions & 0 deletions clay.edn
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
{:remote-repo {:git-url "https://github.com/scicloj/clojure-data-tutorials"
:branch "main"}
:quarto {:title "Clojure Data Tutorials"
:format {:html
{:grid
{:sidebar-width "500px"
:body-width "2500px"
:margin-width "500px"}}}
:include-in-header {:text "<meta property=\"og:image\" content=\"https://scicloj.github.io/sci-cloj-logo-transparent.png\"/>
<meta property=\"og:title\" content=\"Clojure Data Tutorials\"/>
<meta property=\"og:description\" content=\"A collection of community-contributed tutorials for the emerging Clojure data stack\"/>
Expand Down
39 changes: 39 additions & 0 deletions projects/ml/llm/java/hello/Main.java
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);

}

}
61 changes: 61 additions & 0 deletions projects/ml/llm/pom.xml
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>

0 comments on commit a1d616b

Please sign in to comment.