# US 2025/0094816 A1 · Llm fine-tuning for text generation

> Agents: this data is available as JSON from the patentgrep API and MCP server — see https://patentgrep.com/llms.txt

- Number: US 2025/0094816 A1
- Document ID: US20250094816A1
- Status: Published application
- Kind: A1
- Application number: 18/650,904
- Filed: 2024-04-30
- Published: 2025-03-20
- Earliest claimed: 2023-09-15
- Applicants: Oracle International Corporation
- Inventors: Yazhe HU; Mengqing GUO; Zheng WANG; Tao SHENG; Jun QIAN; Vinod MAMTANI
- Web page: https://patentgrep.com/patent/US20250094816A1

## CPC

- H04L 51/02: using automatic reactions or user delegation, e.g. automatic replies or chatbot-generated messages
- G06F 8/35: model driven
- G06F 8/36: Software reuse
- G06F 40/226: Validation
- G06F 40/30: Semantic analysis
- G06F 40/35: Discourse or dialogue representation
- G06F 40/56: Natural language generation
- G06N 3/0895: Weakly supervised learning, e.g. semi-supervised or self-supervised learning
- G06N 3/091: Active learning
- H04L 51/04: Real-time or near real-time messaging, e.g. instant messaging [IM]
- H04L: TRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION (arrangements common to telegraphic and telephonic communication H04M)
- G06F: ELECTRIC DIGITAL DATA PROCESSING (computer systems based on specific computational models G06N)
- G06N: COMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS

## Abstract

Systems, methods, and other embodiments associated with automated fine-tuning of text generation for large language models are described herein. In one embodiment, a method accesses a collection of text samples. The text samples include a natural language text prompt that combines content and instructions. The method extracts the instructions from the text prompt. The method fine-tunes a large language model to generate text in natural language based on a text generation loss function that penalizes non-compliance with the extracted instructions by a generated text response to the text prompt. The method generates an evaluation score for performance of the tuned large language model as a text generator based on a value of the text generation loss function for a second generated text response. And, the method automatically signals that the fine tuning of the tuned large language model is complete in response to the evaluation score satisfying a threshold.

## Claims

### Claim 1

One or more non-transitory computer-readable media that include stored thereon computer-executable instructions that when executed by at least a processor cause a computing system to:
access a collection of text samples, wherein the text samples include a natural language text prompt that combines content and instructions;
parse the text samples to extract the instructions from the text prompt;
fine-tune a large language model to generate text in natural language based on a text generation loss function that penalizes non-compliance with one or more of the extracted instructions by a generated text response to the text prompt;
generate an evaluation score for performance of the tuned large language model as a text generator based on a value of the text generation loss function for a second generated text response; and
automatically determine to deploy the tuned large language model to a production environment for text generation in response to the evaluation score satisfying a threshold.

### Claim 2 (depends on 1)

The non-transitory computer-readable media of claim 1, wherein the computer-executable instructions further cause the computer system to generate a value of format loss that indicates an extent to which the generated text response complies with one or more of the extracted instructions that specify a format of the generated text response.

### Claim 3 (depends on 1)

The non-transitory computer-readable media of claim 1, wherein the computer-executable instructions further cause the computer system to generate a value of length loss that indicates an extent to which the generated text response complies with one or more of the extracted instructions that specify a length of the generated text response.

### Claim 4 (depends on 1)

The non-transitory computer-readable media of claim 1, wherein the computer-executable instructions further cause the computer system to generate a value of narrative loss that indicates an extent to which the generated text response complies with one or more of the extracted instructions that specify a narrative perspective of the generated text response.

### Claim 5 (depends on 1)

The non-transitory computer-readable media of claim 1, wherein the computer-executable instructions further cause the computer system to generate a value of repetitive loss that indicates an extent to which one or more portions of the generated text response substantially repeat.

### Claim 6 (depends on 1)

The non-transitory computer-readable media of claim 1, wherein the computer-executable instructions further cause the computer system to generate a value of embedding similarity loss that indicates an extent to which the generated text response diverges semantically from the text prompt.

### Claim 7 (depends on 1)

The non-transitory computer-readable media of claim 1, wherein the computer-executable instructions further cause the computer system to:
automatically generate a prompt to an additional large language model that requests generation of one or more of a loss value for format loss, a loss value for length loss, a loss value for narrative loss, or a loss value for repetitive loss;
automatically submit the prompt to the additional large language model to cause the additional large language model to generate the one or more loss values; and
base the text generation loss function on the loss values generated by the additional large language model.

### Claim 8

A computing system, comprising:
at least one processor connected to at least one memory;
one or more non-transitory computer readable media including instructions stored thereon that when executed by at least the processor cause the computing system to:
access a collection of text samples, wherein the text samples include a natural language text prompt that combines content and instructions;
parse the text samples to extract the instructions from the text prompt;
fine-tune a large language model to generate text in natural language based on a text generation loss function that penalizes non-compliance with one or more of the extracted instructions by a generated text response to the text prompt;
generate an evaluation score for performance of the tuned large language model as a text generator based on a value of the text generation loss function for a second generated text response; and
automatically determine to deploy the tuned large language model to a production environment for text generation in response to the evaluation score satisfying a threshold.

### Claim 9 (depends on 8)

The computing system of claim 8, wherein the computer-executable instructions for fine-tuning a large language model further include instructions that when executed by the processor cause the computing system to generate the value for the text generation loss function based on combining:
a value of format loss that indicates an extent to which the generated text response complies with one or more of the extracted instructions that specify a format of the generated text response;
a value of length loss that indicates an extent to which the generated text response complies with one or more of the extracted instructions that specify a length of the generated text response; and
a value of narrative loss that indicates an extent to which the generated text response complies with one or more of the extracted instructions that specify a narrative perspective of the generated text response.

### Claim 10 (depends on 8)

The computing system of claim 8, wherein the computer-executable instructions for fine-tuning a large language model further include instructions that when executed by the processor cause the computing system to generate embedding similarity loss by:
embedding the text prompt into a first vector;
embedding the generated response into a second vector; and
determining a cosine distance between the first vector and the second vector as the embedding similarity loss;
wherein the text generation loss function is based in part on the embedding similarity loss.

### Claim 11 (depends on 8)

The computing system of claim 8, wherein the computer-executable instructions for fine-tuning a large language model further include instructions that when executed by the processor cause the computing system to generate a repetitive loss by:
separating the generated response into individual tokens;
performing one or more of a token frequency analysis, an n-gram analysis, a lexical diversity analysis, a cosine distance analysis, a recall analysis, a precision analysis, or a pattern matching analysis of the tokens; and
combining results from the one or more analyses in a weighted average as the repetitive loss;
wherein the text generation loss function is based in part on the repetitive loss.

### Claim 12 (depends on 8)

The computing system of claim 8, wherein the computer-executable instructions for fine-tuning a large language model further include instructions that when executed by the processor cause the computing system to generate the value for the text generation loss function based on a value of loss that indicates an extent to which the generated text response complies with one or more of the extracted instructions that specifies one of tone, writing style, vocabulary, audience, inclusion of information, or exclusion of information.

### Claim 13 (depends on 1)

The non-transitory computer-readable media of claim 1, wherein the computer-executable instructions further cause the computer system to analyze the generated text response for compliance with extracted instructions using an additional large language model, wherein the text generation loss function is based at least in part on the analysis by the additional large language model.

### Claim 14

A computer-implemented method, comprising:
accessing a collection of text samples, wherein the text samples include a natural language text prompt that combines content and instructions;
extracting the instructions from the text prompt;
fine-tuning a large language model to generate text in natural language based on a text generation loss function that penalizes non-compliance with one or more of the extracted instructions by a generated text response to the text prompt;
generating an evaluation score for performance of the tuned large language model as a text generator based on a value of the text generation loss function for a second generated text response; and
automatically signaling that the fine tuning of the tuned large language model is complete in response to the evaluation score satisfying a threshold.

### Claim 15 (depends on 14)

The computer-implemented method of claim 14, further comprising:
determining an extracted instruction to be of a particular type of instruction;
evaluating the extracted instruction with a component loss function of the text generation loss function that assesses compliance by the generated text response with the particular type of instruction; and
incorporating output of the component loss function into the text generation loss function.

### Claim 16 (depends on 14)

The computer-implemented method of claim 14, wherein fine-tuning the large language model further comprises:
generating a value of instruction loss that indicates an extent to which the generated text response complies with one or more of the extracted instructions;
generating a value of repetitive loss that indicates an extent to which one or more portions of the generated text response substantially repeat;
generating a value of embedding similarity loss that indicates an extent to which the generated text response diverges semantically from the text prompt; and
combining the values of instruction loss, repetitive loss, and embedding similarity loss in the text generation loss function.

### Claim 17 (depends on 14)

The computer-implemented method of claim 14, wherein fine-tuning the large language model further comprises generating an embedding similarity loss between a first embedding of the natural language text prompt and a second embedding of the generated text response in a vector space, wherein the embedding similarity loss is based on difference of alignment between the first embedding of the natural language text prompt and the second embedding of the generated text response.

### Claim 18 (depends on 14)

The computer-implemented method of claim 14, further comprising generating the value for the text generation loss function based at least in part on a value of loss that indicates an extent to which the generated text response complies with one or more of the extracted instructions that specifies one of tone, writing style, vocabulary, audience, inclusion of information, or exclusion of information.

### Claim 19 (depends on 14)

The computer-implemented method of claim 14, wherein a condition of satisfying the threshold includes surpassing a previous best for the evaluation score, the method further comprising comparing the evaluation score to the previous best for the evaluation score.

### Claim 20 (depends on 14)

The computer-implemented method of claim 14, further comprising analyzing the generated text response for compliance with extracted instructions using an additional large language model, wherein the text generation loss function is based at least in part on the analysis by the additional large language model.
