Skip to main content

Large Language Models: How to use open source alternatives to ChatGPT for Scala documentation

Picture of Joanna Sendorek, Senior Data Scientist

Joanna Sendorek

Senior Data Scientist
Picture of Paulina Żak, Senior ML Engineer

Paulina Żak

Senior ML Engineer
May 19, 2023|15 min read
Large Language Models: How to use open source alternatives to ChatGPT for Scala documentation image
gpt-4

bert-1

bert-2

flan-alpaca-large

msmarco-distilbert-base-v4

lang-chain

1How to convert case class Person(name: String, surname: String) into Json?
2--------------------------------------
3ChatGPT
4"You can use the ujson library's write method to convert a case class into JSON format. Here's an example:\n\n```scala\nimport ujson._\ncase class Person(name: String, surname: String)\nval person = Person(\"John\", \"Doe\")\nval json = write(person)\nprintln(json) // Prints out {\"name\":\"John\",\"surname\":\"Doe\"}\n```\n\nIn this example, we import the ujson library and define a case class called Person. We then create an instance of the Person class and use the write method to convert it into a JSON string. Finally, we print out the JSON string."
5--------------------------------------
6Openai da vinci
7" You can use the ujson library to convert a case class into a JSON string. For example, you can use the ujson.write method to convert a Person instance into a JSON string:\n\nval person = Person(\"John\", \"Doe\")\nval jsonString = ujson.write(person)\nprintln(jsonString) // Prints out {\"name\":\"John\",\"surname\":\"Doe\"}"
8--------------------------------------
9flan t5 xl
10"ujson.read(name) print(\"\"\"\"name\": \"Peter\", \"age\": 13\"\"\"\"\" )"
11--------------------------------------
12flan t5 xxl
13"scala case class Person(name: String, surname: String) json"
14--------------------------------------
15gpt4all
16You can define a Writer like this and use it in the help method. Then you need an implicit for Writes[Person]."
17--------------------------------------
18alpaca-t5-xl
19"\"name\": \"Peter\", \"age\": 13\"\" "
20--------------------------------------
21declare-lab/flan-sharegpt-xl
22""
23--------------------------------------
1You are going to create Questions and Answers based on fragments of Scala 3 documentation given in a context.
2Requirements:
31. The documentation is in a markdown file, but in output, no markdown artefact should be presented.
42. The answer should come from the documentation fragment provided. Questions and answers should work standalone without previous information.
53. Be short and precise.
64. The questions should be strictly technical and should answer common developers questions. Questions like: “What is the title of the document the information is taken from?” is not allowed
75. Replace demonstrative pronouns with use <DOC NAME> instead in phrases like “this document”
86. Questions and answers should make sense without context, no phrases like “given fragment”, “given document”
9If the fragment is from a larger document, you will be given a summarization of the whole document, but use it only for the context. Do not create questions based on summarization.
10If you cannot extract at least 5 relevant and technical questions with answers from the context fragment, return <NO QUESTIONS GENERATED>
11Example:
12Q: What is @main annotation?
13A: Method with `@main` annotation is an entry point to a program.
14Q: How to write a test using a temporary file?
15A: Use `FunFixture` from munit. eg val usingTempFile: FunFixture[os.Path] = FunFixture(setup = _ => os.temp(prefix = "file-tests"), teardown = tempFile => os.remove(tempFile)); usingTempFile.test(<name>){{ <your test> }}
16Q: How to change the jvm version in Scala CLI?
17A: You can use the --jvm flag `scala-cli --jvm 8 Main.scala`
18Document name: [DOC NAME]
19{f'Summarization: {summarization}' if summarization else ''}
20Context fragment:
21{fragment.page_content} .
22Remember, If you cannot extract at least 5 relevant and technical answers from the context fragment return less than 5 questions or text<NO QUESTIONS GENERATED>
23Answers should come directly from the context fragment.
24Create 5 questions with answers. Let's take it step by step. “””}

Curated by Sebastian Synowiec

Subscribe to our newsletter and never miss an article