Book a free call

Domain-Specific SLMs for Legal and Medtech: How They Work

A domain-specific small language model is a compact model trained on one field's texts, such as law or medicine, so it handles that field's language better.

Hertiv engineering teamReviewed by a senior engineer
7 min read
Domain-Specific SLMs for Legal and Medtech: How They Work
On this page

Short answer

A domain-specific small language model, or SLM, is a compact language model trained or tuned on the texts of one field, such as law or medicine, so it handles that field's language, documents and tasks better than a general model of the same size. It trades broad knowledge for depth in one area, which makes it cheaper to run and easier to keep inside an organisation's own systems.

What is a domain-specific SLM?

A domain-specific small language model is a language model built for one field. Instead of training on the whole internet, it is trained or tuned on the documents of a single profession, such as contracts and case law for lawyers, or clinical notes and guidelines for medtech teams. The result is a model that knows the vocabulary, the document shapes and the common tasks of that field.

Small here means small compared with a large general model. An SLM has far fewer parameters, needs less computing power to run, and can often run on a company's own servers or even on a single powerful machine. That matters in law and medicine, where client and patient data often cannot leave the organisation.

The model is not a smaller copy of a general chatbot. It is a specialist: good at the documents and questions of its field, and weaker outside it. A legal SLM that drafts contract summaries will not write good marketing copy, and nobody should expect it to.

FeatureGeneral large modelDomain-specific SLM
Training dataBroad web and booksOne field's documents
Size and cost to runLarge, cloud onlyCompact, can run on-premise
Field vocabularyGeneralDeep and specific
Data privacyData leaves the officeData can stay in-house
Best useOpen questionsRepeated field tasks

Most teams do not build an SLM from scratch. They start from an existing open model and tune it on their own documents, which is far cheaper and faster than training a new model. For the difference between the two sizes, see the SLM vs LLM comparison.

Why use a small model instead of a large general one?

A small domain model wins on four things: cost, speed, privacy and accuracy on narrow tasks. A large general model can do more kinds of tasks, but for a repeated task inside one field, the specialist usually does the job better and cheaper.

Cost is the simplest reason. Running a large model for every document costs money on every call, and the bill grows with volume. A small model running on your own hardware has a fixed cost, so a team that processes thousands of documents a month can save a lot. Speed follows the same logic: a small model answers faster, which matters when a lawyer or clinician is waiting on a summary.

Privacy is often the deciding reason. Law firms hold client confidences and medtech companies hold patient data, and in many cases that data cannot be sent to an outside service. An SLM that runs on-premise keeps the data inside the organisation, which makes compliance reviews far simpler.

Accuracy on narrow tasks is the last reason. A general model may know a little about every area of law, but a model tuned on your firm's own contracts knows your clauses, your templates and your standard positions. That is the difference between a plausible summary and a useful one.

How are domain-specific SLMs built?

A domain SLM is built in five steps, and the data work takes most of the time. Teams that rush the data end up with a model that sounds confident and is wrong in the details.

  1. Collect the field's texts. Contracts, filings, guidelines, clinical notes and manuals, cleaned and checked for quality.
  2. Clean and label the data. Remove duplicates, fix errors and mark up examples of the tasks the model must do.
  3. Tune a base model. Take an existing open model and train it further on the field data, so it learns the vocabulary and the document patterns.
  4. Add retrieval. Connect the model to a search index of your own documents, so answers are grounded in sources you control.
  5. Evaluate with experts. Have lawyers or clinicians test the model on real tasks and score the output before it goes near live work.

Evaluation is where most projects succeed or fail. A model that scores well on a generic test can still miss the details that matter in a contract or a clinical note, so the test set must come from the field itself. The experts who will use the model should write the test questions.

Once live, the model needs ongoing care. New laws, new guidelines and new document types all change what good output looks like, so plan for regular retraining and review. A document AI setup that keeps the source documents organised makes this far easier.

In legal work, domain SLMs help with the reading and drafting that fills a lawyer's day. They do not replace legal judgement, but they clear the routine work so lawyers spend their time on the decisions that need a person.

Contract review is the most common use. A model can read a contract, list the key clauses, flag terms that differ from the firm's standard positions, and draft a summary for the lawyer to check. Clause search is similar: instead of searching by keyword, a lawyer asks for the clauses that cover a topic and gets the relevant text with its location.

Drafting is the next use. The model can produce a first version of a standard document, such as a non-disclosure agreement or a service agreement, from the firm's own templates. The lawyer then edits it, which is faster than writing from a blank page and keeps the firm's wording consistent.

Case preparation is a third use. A model can summarise long filings, pull out the timeline of events, and find the documents that support a particular point. The lawyer still checks every citation, because a model that invents a case reference is worse than no model at all. That check is part of the workflow, not an optional extra.

Where do they help in medtech?

In medtech, domain SLMs help with the paperwork around care and research. They support clinicians and product teams, and they never make clinical decisions on their own.

Clinical documentation is the biggest use. A model can turn a consultation transcript into a structured note, draft a discharge summary, or extract the key facts from a long patient record. The clinician reviews and signs the result, which is what makes the workflow safe: the model drafts, a person decides.

Coding and billing is a second use. Clinical notes must be coded into standard terms for records and billing, and a model tuned on medical language can suggest the right codes for a clinician to confirm. Literature search is a third: a model can search guidelines and research papers and return the relevant passages, with sources, instead of a plain keyword list.

The rules here are stricter than in law. Medical data is sensitive, models that touch care need clinical validation, and regulators in each country set their own requirements for software used in healthcare. Any medtech team building an SLM should involve its regulatory and clinical staff from the first week, not after the model is built. For teams planning this kind of system, AI agent development with a healthcare focus follows the same safety-first pattern.

Example (hypothetical): a 30-lawyer firm reviews contracts faster

Example (hypothetical): a law firm with 30 lawyers reviews about 200 contracts a month. Each contract takes a lawyer about 45 minutes to read and summarise, which is 9,000 minutes, or 150 hours, of lawyer time a month.

The firm tunes a small model on its own contract templates and past agreements. The model produces a first-pass summary and a list of clauses that differ from the firm's standard positions. The lawyer then checks the summary and the flagged clauses instead of reading the whole contract from scratch, which takes about 25 minutes per contract, or 5,000 minutes, about 83 hours a month.

The saving is about 67 hours of lawyer time a month. At an assumed internal cost of $150 an hour, that is about $10,000 a month. The model cost the firm a few weeks of data work and a modest server, and every output is still checked by a lawyer, so the saving comes from reading faster, not from removing the review.

What are the common mistakes?

The most common mistakes are training on poor data, skipping expert evaluation, and letting the model answer questions it was never built for.

  • Dirty training data. Old templates, duplicate documents and mislabelled examples teach the model the wrong patterns.
  • No expert testing. A generic benchmark cannot tell you whether a legal summary or a clinical note is safe to use.
  • No human check. In law and medicine, every output that affects a client or a patient needs a person to review it.
  • Using it outside its field. A legal SLM will answer a medical question with the same confidence, and be wrong.
  • Sending sensitive data out. If the model runs outside your systems, client and patient data leave with it.
  • Forgetting maintenance. Laws and guidelines change, so a model that is never retrained quietly goes out of date.

Key takeaways

  • A domain SLM is a compact model tuned on one field's documents, not a smaller general chatbot
  • Small models win on cost, speed and privacy, and can run on-premise where data must stay in-house
  • Most teams tune an existing open model rather than training one from scratch
  • In law they help with contract review, clause search and first drafts; in medtech with notes, coding and literature search
  • Every output that affects a client or a patient needs a human to review it

Frequently asked questions

What is a domain-specific SLM?

A domain-specific small language model is a compact language model trained or tuned on the documents of one field, such as law or medicine. It handles that field's vocabulary, document shapes and repeated tasks better than a general model of the same size, and it can often run on the organisation's own servers.

Are SLMs as accurate as large models?

On their own field, a well-tuned SLM can match or beat a large general model, because it knows the field's language and documents. Outside that field it is weaker. The right question is not which model is better in general, but which one is better at the specific task you need.

Can a law firm use an SLM without sending data to the cloud?

Yes, if the model is small enough to run on the firm's own servers. That is one of the main reasons firms choose SLMs: client data stays inside the organisation. The firm still needs to manage the servers, updates and access controls.

Do medtech SLMs need regulatory approval?

It depends on the country and on what the model does. Software that supports clinical decisions faces stricter rules than software that drafts internal summaries. Medtech teams should involve regulatory and clinical staff early, because the answer changes the whole project plan.

How much data does it take to tune an SLM?

There is no single number, because it depends on the task and the base model. A useful rule is that a few thousand good examples of the actual task matter more than a huge pile of unlabelled documents. Data quality decides the result far more than data volume.

What does it cost to run a domain SLM?

It varies with model size, hardware and volume, but the cost is usually a fixed infrastructure cost rather than a per-call fee. Teams that process thousands of documents a month often find this cheaper than paying a large-model provider for every call. Ask vendors for a price on your actual volume.

Found this useful? Share it.
Hertiv engineering team

Written from projects we build for clients: software products in production. Every post is reviewed by a senior engineer before publishing and updated when practice changes.

About HertivHow we work

Planning a domain-specific model for legal or medtech work? Talk to Hertiv.

A senior engineer replies within one business day. Or see our Document AI & OCR service.

Book a free call

Keep reading

All posts

Tell us what you want to build

A senior engineer reads every request and replies within one business day with questions, a rough range, or a call link.

  • NDA on request before any details
  • You own all code, models and IP
  • US, UK and EU time-zone overlap

Your email app should open with your message ready to send. If it does not, write to [email protected].

Prefer email? Write to [email protected]
Estimate costBook a call