3  Text Generation

One of the primary uses of Large Language Models (LLMs) is their ability to generate high-quality textual content, making them invaluable in a variety of applications. Common examples include automated content creation for blogs and social media posts, intelligent chatbots that engage in natural conversations, and multilingual translations that maintain accuracy and fluency. These models can produce coherent narratives, informative summaries, and conversational responses that closely mimic human writing styles.

In this chapter, we will explore how to perform text generation tasks in R using the rollama package (Gruber & Weber, 2024) for a variety of relevant use cases in academic and medical research. For the generated text, you will actually get different results from mine due to the random nature of text generation process.

3.1 Preliminaries

Load these packages,

Make sure that your Ollama is running,

ping_ollama()  # ensure it's running
▶ Ollama (v0.5.1) is running at <http://localhost:11434>!
# list_models()$name #> run this to view available models in your system

Give names to our buddies,

llama = "llama3.2:3b"
malay = "hf.co/RichardErkhov/mesolitica_-_malaysian-llama-3-8b-instruct-16k-gguf:Q4_K_M"

3.2 Interpreting Statistical Results

Run a linear regression using the multi-purpose dataset mtcars,

lm_model = lm(mpg ~ wt, data = mtcars)
summary(lm_model)

Call:
lm(formula = mpg ~ wt, data = mtcars)

Residuals:
    Min      1Q  Median      3Q     Max 
-4.5432 -2.3647 -0.1252  1.4096  6.8727 

Coefficients:
            Estimate Std. Error t value Pr(>|t|)    
(Intercept)  37.2851     1.8776  19.858  < 2e-16 ***
wt           -5.3445     0.5591  -9.559 1.29e-10 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 3.046 on 30 degrees of freedom
Multiple R-squared:  0.7528,    Adjusted R-squared:  0.7446 
F-statistic: 91.38 on 1 and 30 DF,  p-value: 1.294e-10

Save the output into a suitable text format,

text_data = summary(lm_model) |> capture.output() |> paste(collapse = "\n")

Put everything together nicely in a tibble,

q_text = tribble(
  ~role,    ~content,
  "system", "Interpret the statistical results from the given text:",
  "user",   text_data
)
q_text

Query to interpret the statistical result,

query(q_text, llama, output = "text", screen = FALSE) |> cat()
**Regression Analysis Results**

The statistical results from the given text are for a simple linear regression analysis of `mpg` (miles per gallon) in the `mtcars` dataset as a function of `wt` (weight). Here's an interpretation of the key statistics:

**Residuals:**

* The residual plot shows that there is a slight upward trend, indicating some non-linear relationships or outliers that may affect the model's accuracy.
* The residuals are approximately normally distributed, with most values clustering around 0.

**Coefficients:**

* **Intercept (Constant):**
    + Estimated value: 37.2851
    + Standard error: 1.8776
    + t-value: 19.858 (highly significant)
    + p-value: <2e-16 (very strong evidence against the null hypothesis that the intercept is 0)
* **Slope (Weight):**
    + Estimated value: -5.3445
    + Standard error: 0.5591
    + t-value: -9.559 (highly significant)
    + p-value: 1.29e-10 (strong evidence against the null hypothesis that the slope is 0)

**Model Statistics:**

* **Residual standard error:** 3.046 on 30 degrees of freedom, indicating moderate variability in the residuals.
* **Multiple R-squared:** 0.7528, indicating a significant linear relationship between `mpg` and `wt`.
* **Adjusted R-squared:** 0.7446, which is slightly lower than the multiple R-squared due to the presence of non-constant variance (heteroscedasticity).
* **F-statistic:** 91.38 on 1 and 30 degrees of freedom, with a p-value: 1.294e-10.
* The F-statistic indicates that the model is highly significant at any plausible level.

**Conclusion:**

The linear regression model provides a good fit to the data, indicating that `mpg` is negatively related to `wt`. This makes sense physically, as heavier cars tend to have lower fuel efficiency. However, there are some residual issues (outliers and upward trend) that may require further investigation or modeling adjustments.

3.3 Writing Knowledge Questions

3.3.1 English

Write the LLM role and user query,

system_instruction = "
You are an expert in public health. Currently you are tasked to write questions 
according to given query. Give answers to each question. Take into account 
target population of the questions.
"
user_query = "
Write 10 knoweldge questions about malaria for general public with low education level.
"

Combine these in a tibble,

q_text = tribble(
  ~role,    ~content,
  "system", system_instruction,
  "user",   user_query
)
q_text

Ask the LLM. Look at Question 2, what’s wrong? That’s why we must evaluate texts given by LLM carefully.

query(q_text, llama, output = "text", screen = FALSE) |> cat()
Here are 10 knowledge questions about malaria suitable for a general public with low education level:

1. What is malaria?
a) A type of food poisoning
b) A disease that affects the eyes
c) A sickness caused by a tiny parasite that is spread by mosquitoes
d) A type of skin cancer

Answer: c) A sickness caused by a tiny parasite that is spread by mosquitoes

2. Which mosquito is most likely to spread malaria?
a) Housefly
b) Mosquito
c) Sand fly
d) Tsetse fly

Answer: b) Mosquito

3. What are the symptoms of malaria?
a) Fever, chills, and headache
b) Diarrhea, vomiting, and stomach pain
c) Cough, runny nose, and sore throat
d) Muscle weakness, joint pain, and fatigue

Answer: a) Fever, chills, and headache

4. How is malaria typically spread?
a) Through touch or contact with an infected person
b) Through eating contaminated food or water
c) Through the bite of an infected mosquito
d) Through breathing in infected air

Answer: c) Through the bite of an infected mosquito

5. Can anyone get malaria?
a) No, it only affects children and pregnant women
b) Yes, but mostly people who live in tropical areas
c) Only people with weak immune systems
d) Everyone can get malaria if bitten by an infected mosquito

Answer: d) Everyone can get malaria if bitten by an infected mosquito

6. How is malaria diagnosed?
a) By looking at the patient's symptoms and medical history
b) By performing a blood test to check for the parasite
c) By examining the patient's stool or urine
d) By doing a physical examination of the patient's body

Answer: b) By performing a blood test to check for the parasite

7. What is the treatment for malaria?
a) Taking antibiotics
b) Drinking plenty of water and resting
c) Taking antimalarial medication such as chloroquine or artemisinin
d) Getting a vaccine to prevent it from happening again

Answer: c) Taking antimalarial medication such as chloroquine or artemisinin

8. Can malaria be prevented?
a) Yes, by wearing long-sleeved clothes and applying insecticide
b) No, it's only a matter of luck if you get bitten by an infected mosquito
c) Only pregnant women can prevent malaria with special medication
d) By eating more fruits and vegetables

Answer: a) Yes, by wearing long-sleeved clothes, applying insecticide, and taking preventive measures such as using bed nets

9. How can I protect myself from mosquitoes that may carry malaria?
a) Wear dark colors to blend in with the surroundings
b) Avoid going outside during peak mosquito hours
c) Use a net around your bed to keep mosquitoes away
d) Use insecticide on your skin and clothes

Answer: c) Use a net around your bed to keep mosquitoes away and b) Avoid going outside during peak mosquito hours

10. Who is most at risk of getting malaria?
a) People who live in urban areas
b) Children under 5 years old
c) Pregnant women
d) All of the above

Answer: d) All of the above, especially those living in tropical and subtropical regions

3.3.2 Malay

Write the LLM role and user query,

system_instruction = "
Anda pakar dalam kesihatan awam. Anda ditugaskan untuk menulis soalan. 
Beri jawapan kepada setiap soalan yang anda tulis. Ambil kira populasi sasaran soalan.
"
user_query = "
Tulis 10 soalan pengetahuan tentang demam denggi untuk orang awam.
"

At the moment, for this Malaysian LLM, you need to simplify the instructions as it is still in its early stages. Note that the model understands English because it is based on LLama 3 (note the model’s name). You may also explore the MaLLaM model (https://mesolitica.com/mallam).

Combine these in a tibble,

q_text = tribble(
  ~role,    ~content,
  "system", system_instruction,
  "user",   user_query
)
q_text

Ask the Malaysian LLM hf.co/RichardErkhov/mesolitica_-_malaysian-llama-3-8b-instruct-16k-gguf:Q4_K_M,

query(q_text, malay, output = "text", screen = FALSE) |> cat()
Sudah tentu, saya boleh membantu. Berikut adalah beberapa soalan dan jawapan mengenai demam denggi:

1. Apakah demam denggi?
Demam denggi ialah penyakit yang disebabkan oleh jangkitan virus Denggi.

2. Bagaimana demam denggi merebak?
Demam denggi merebak melalui gigitan nyamuk Aedes aegypti yang membawa virus Denggi.

3. Apakah gejala demam denggi?
Gejala awal demam denggi termasuk demam tinggi, sakit kepala, ruam kulit dan loya-loya. Gejala lain termasuk keletihan, muntah-muntah, dan gangguan pernafasan.

4. Apakah faktor risiko jangkitan demam denggi?
Faktor risiko jangkitan demam denggi ialah tinggal di kawasan yang terdapat banyak nyamuk Aedes aegypti, seperti kawasan bandar atau pinggir bandar.

5. Bagaimana cara mencegah penularan demam denggi?
Cara mencegah penularan demam denggi termasuk mengelakkan gigitan nyamuk dengan memakai pakaian yang menutupi kulit, menggunakan repelan serangga, dan membersihkan tempat pembiakan nyamuk seperti kolam atau bekas air yang bertakung.

6. Bagaimana cara mengenal pasti demam denggi?
Demam tinggi adalah salah satu gejala utama demam denggi. Gejala lain termasuk ruam kulit, sakit kepala, dan gangguan pernafasan.

7. Adakah rawatan untuk demam denggi wujud?
Ya, terdapat beberapa jenis ubat yang boleh digunakan untuk merawat demam denggi, seperti parasetamol untuk mengurangkan demam dan ubat anti-radang untuk meredakan gejala.

8. Apakah risiko jangkitan semula demam denggi?
Jika anda pernah menghidap demam denggi sebelum ini, risiko jangkitan semula boleh meningkat jika tidak berhati-hati dalam menjaga kebersihan dan mencegah gigitan nyamuk.

9. Bagaimana cara menguruskan gejala demam denggi?
Adalah penting untuk memantau gejala anda dan segera mencari bantuan perubatan jika mengalami sakit kepala yang teruk, gangguan pernafasan, atau tanda-tanda komplikasi lain.

10. Adakah vaksin untuk demam denggi?
Pada masa ini, tiada vaksin berkesan tersedia untuk melindungi daripada jangkitan demam denggi. Walau bagaimanapun, penyelidikan dan pembangunan terus dijalankan untuk mencari penyelesaian yang lebih baik dalam mencegah dan mengawal demam denggi.

Saya harap jawapan ini membantu! Jika anda memerlukan maklumat lanjut, sila beritahu saya.

3.4 R Coding

Specify your coding problem,

q_text = "
Show how to perform a logistic regression analysis in R programming language.
"

Ask for help. Here we try a larger model, qwen2.5-coder, a 7B model.

coder = "qwen2.5-coder:7b"
query(q_text, coder, output = "text", screen = FALSE) |> cat()
To perform a logistic regression analysis in R, you can use the glm() function which stands for Generalized Linear Model.

Firstly, make sure that you have a dataset. If not, you could use the built-in 'mtcars' or 'iris' datasets or create your own dataset.

Let's say our data is stored in 'data', and we want to perform logistic regression on a binary outcome variable called 'outcome' based on several predictor variables including 'predictor1', 'predictor2', etc. 

The glm() function can be used as follows:

```{r}
# Load the necessary library if not already loaded
library(stats)

# Define the formula for your model. The formula here is logistic regression with outcome dependent on predictor1 and predictor2.
model_formula <- outcome ~ predictor1 + predictor2

# Use glm to fit a logistic regression model using the defined formula and data
logistic_model <- glm(model_formula, data = data, family=binomial())

# Summary of the model output
summary(logistic_model)
```

The summary will provide the coefficients for your predictors which indicate their influence on the likelihood of the outcome.

Remember to replace 'outcome', 'predictor1', and 'predictor2' with your actual variable names.

Also, always remember that when it comes to logistic regression, it is crucial to check the assumptions of this model. This includes checking if the relationship between the independent variables and the logit of the dependent variable is linear, whether all the observations have equal weights (no overfitting or underfitting), and finally checking for the independence of errors (there should be no correlation among residuals). 

In case the assumptions are not met, you might need to consider using a different model.

3.5 Reference Formatter

References can be converted from one referencing format to another. Here, we have several references to be formatted (taken from https://doi.org/10.1016/j.gore.2022.101024),

refs = "
Bekkers, S., Bot, A.G., Makarawung, D., et al., 2014. The National Hospital Discharge
Survey and Nationwide Inpatient Sample: the databases used affect results in THA
research. Clin. Orthop. Relat. Res. 472, 3441–3449.

Chubak, J., Ziebell, R., Greenlee, R.T., Honda, S., et al., 2016. The Cancer Research
Network: a platform for epidemiologic and health services research on cancer
prevention, care, and outcomes in large, stable populations. Cancer Causes Control.
27 (11), 1315–1323.

Dreyer, N.A., Tunis, S.R., Berger, M., Ollendorf, D., Mattox, P., Gliklich, R., 2010. Why
observational studies should be among the tools used in comparative effectiveness
research. Health Aff. (Millwood). 29 (10), 1818–1825.

Husereau, D., Drummond, M., Augustovski, F., et al., 2022. Consolidated health
economic evaluation reporting standards 2022 (CHEERS 2022) statement: updated
reporting guidance for health economic evaluations. Int. J. Technol. Assess. Health
Care. 38 (1).
"

Place everything together nicely in a tibble,

q_text = tribble(
  ~role,    ~content,
  "system", "Convert the given references in APA 7 format. Do not comment or elaborate.",
  "user",   refs
)
q_text

Ask it to do the job,

query(q_text, llama, output = "text", screen = FALSE,
      model_params = list(num_ctx = 2000)) |> cat()
Bekkers, S., Bot, A. G., Makarawung, D., et al., (2023, December). The National Hospital Discharge Survey and Nationwide Inpatient Sample: the databases used affect results in Total Hip Arthroplasty research. Journal of Orthopaedic Research, 472(10), 3441–3449.

Chubak, J., Ziebell, R., Greenlee, R. T., Honda, S., et al., (2022). The Cancer Research Network: a platform for epidemiologic and health services research on cancer prevention, care, and outcomes in large, stable populations. Cancer Causes Control, 27(10), 1315–1323.

Dreyer, N. A., Tunis, S. R., Berger, M., Ollendorf, D., Mattox, P., Gliklich, R., (2020). Why observational studies should be among the tools used in comparative effectiveness research. Health Affairs, 39(10), 1818–1825.

Husereau, D., Drummond, M., Augustovski, F., et al., (2023). Consolidated health economic evaluation reporting standards 2022 (CHEERS 2022) statement: updated reporting guidance for health economic evaluations. International Journal of Technology Assessment in Health Care, 39(1), e123–e134.

Here we increase the context window to 2000. Context window/size is number of tokens that can be LLM can receive/produce as input/output. It is around 3/2 times words in a given text. Please ask your LLM companion for more information about it :-)

3.6 Summarizing Abstracts From PubMed

Get abstract from PubMed on Partial verification bias from year 2020 until 2025. This requires pubmedR (Aria, 2020) and bibliometrix (Aria & Cuccurullo, 2017, 2024) packages.

library(pubmedR)
library(bibliometrix)
library(stringr)
api_key = NULL
query_pvb = "partial verification bias*[Title/Abstract] AND english[LA] AND Journal Article[PT] AND 2020:2025[DP]"
res = pmQueryTotalCount(query = query_pvb, api_key = api_key)
D = pmApiRequest(query = query_pvb, limit = res$total_count, api_key = api_key)
Documents  14  of  14 
M = convert2df(D, dbsource = "pubmed", format = "api")

Converting your pubmed collection into a bibliographic dataframe

=============================================================================
Done!

Save relevant abstracts in text_abs. We may flatten the abstracts into a single text string, text_abs_flat,

key = grep("PARTIAL VERIFICATION BIAS", M$TI)  # Select abstract with "partial verification bias"
text_abs = M$AB[key]
text_abs_flat = str_flatten(M$AB[key])

Estimate the context size required by the LLM model,

ctx = str_length(text_abs_flat) * 3 / 2
ctx = round(ctx, -3)  # with large ctx, be careful with VRAM use
ctx
[1] 5000

Setup the query in a tibble,

q_text = tribble(
  ~role, ~content,
  "system", "Summarize the content of the given text.",
  "user", text_abs_flat,
)

and get the result,

query(q_text, llama, output = "text", screen = FALSE, 
      model_params = list(num_ctx = ctx)) |> cat()
The text discusses the importance of evaluating new diagnostic tests in medical care, particularly when it comes to accuracy measures such as sensitivity (SN) and specificity (SP). However, these measures can be biased due to a phenomenon called partial verification bias (PVB), where only certain patients are verified.

To address this issue, the article introduces Inverse Probability Bootstrapping (IPB) sampling as a method to correct for PVB. IPB is adapted for use in correcting PVB and tested on simulated and clinical data sets. The results show that IPB is accurate for estimating SN and SP, but less precise than existing methods.

The article also discusses alternative approaches to avoiding PVB, such as applying the reference standard to all individuals who are positive on the index test and a random sample of those who are negative. It highlights the need for further research to reduce the standard error (SE) of IPB.

Overall, the text emphasizes the importance of thoroughly evaluating new diagnostic tests in medical care, particularly when it comes to accuracy measures, and discusses various methods available to correct for PVB.

You will notice that it refers to “an article” because we combined the abstracts in a single text.

And we may try using llm_vec_summarize() from mall1 package (Ruiz, 2024) to summarize each abstract in 20 words or less,

library(mall)
llm_use("ollama", llama, .silent = TRUE)
llm_vec_summarize(text_abs, max_words = "20") -> text_abs_summ
text_abs_summ
[1] "ipb is accurate for sn and sp estimation with low bias but less precise than existing methods with higher se."                    
[2] "partial verification bias occurs when a positive index test makes application of the reference standard more likely."             
[3] "new diagnostic tests undergo evaluation comparing to gold standard tests with accuracy measures like sensitivity and specificity."
text_abs_summ |> str_split(" ") |> sapply(length)
[1] 20 17 17

3.7 Extracting Information

We can extract relevant information from a given text. As an example, I provide it with an announcement for a recent webinar,

webinar_text = "
Topic: Easy Data Exploration and Visualization using GWalkR Package in R
Date: 18 January 2025
Time: 9.00pm 
Platform: Webex

Organized by the Malaysian Disease Modelling Expert Group (MDMEG)
"
llm_use("ollama", "gemma2:2b", .silent = TRUE, seed = 111)  # using smaller model; gemma2:2b
llm_vec_extract(webinar_text, c("title", "date", "time", "place", "organizer")) |> cat()
title|date|time|place|organizer
easy data exploration and visualization using gwalkr package in r|january 18, 2025|9:00pm|webex|malasian disease modelling expert group (mdmeg) 

Notice that, although we uses the words “title” and “place” instead of “topic” and “platform”, it could still understand these terms. I also used seed = 111, because I was satisfied with the given response using this seed number. You may try with other seed numbers and see the changes in the responses.

3.8 Translation

We can try the llm_vec_translate() (or llm_translate() if your input is a data frame or tibble) from mall. Here, we translate the first abstract from English to Malay,

text_abs[1] # English text
[1] "IN MEDICAL CARE, IT IS IMPORTANT TO EVALUATE ANY NEW DIAGNOSTIC TEST IN THE FORM OF DIAGNOSTIC ACCURACY STUDIES. THESE NEW TESTS ARE COMPARED TO GOLD STANDARD TESTS, WHERE THE PERFORMANCE OF BINARY DIAGNOSTIC TESTS IS USUALLY MEASURED BY SENSITIVITY (SN) AND SPECIFICITY (SP). HOWEVER, THESE ACCURACY MEASURES ARE OFTEN BIASED OWING TO SELECTIVE VERIFICATION OF THE PATIENTS, KNOWN AS PARTIAL VERIFICATION BIAS (PVB). INVERSE PROBABILITY BOOTSTRAP (IPB) SAMPLING IS A GENERAL METHOD TO CORRECT SAMPLING BIAS IN MODEL-BASED ANALYSIS AND PRODUCES DEBIASED DATA FOR ANALYSIS. HOWEVER, ITS UTILITY IN PVB CORRECTION HAS NOT BEEN INVESTIGATED BEFORE. THE OBJECTIVE OF THIS STUDY WAS TO INVESTIGATE IPB IN THE CONTEXT OF PVB CORRECTION UNDER THE MISSING-AT-RANDOM ASSUMPTION FOR BINARY DIAGNOSTIC TESTS. IPB WAS ADAPTED FOR PVB CORRECTION, AND TESTED AND COMPARED WITH EXISTING METHODS USING SIMULATED AND CLINICAL DATA SETS. THE RESULTS INDICATED THAT IPB IS ACCURATE FOR SN AND SP ESTIMATION AS IT SHOWED LOW BIAS. HOWEVER, IPB WAS LESS PRECISE THAN EXISTING METHODS AS INDICATED BY THE HIGHER STANDARD ERROR (SE). DESPITE THIS ISSUE, IT IS RECOMMENDED TO USE IPB WHEN SUBSEQUENT ANALYSIS WITH FULL DATA ANALYTIC METHODS IS EXPECTED. FURTHER STUDIES MUST BE CONDUCTED TO REDUCE THE SE."
llm_use("ollama", malay, .silent = TRUE, seed = 123)
llm_vec_translate(text_abs[1], language = "Malay")  # Malay text
[1] "Dalam penjagaan kesihatan, adalah penting untuk menilai sebarang ujian diagnostik baharu menggunakan kajian ketepatan diagnostik. Ujian ini dibandingkan dengan ujian standard emas, di mana prestasi ujian diagnostik binari biasanya diukur oleh kepekaan (SN) dan kekhususan (SP). Walau bagaimanapun, ukuran ketepatan ini sering berat sebelah kerana pengesahan terpilih pesakit, yang dikenali sebagai bias pengesahan separa (PVB). Pemampatan butstrap kebarangkalian songsang (IPB) ialah kaedah umum untuk membetulkan berat sebelah pensampelan dalam analisis berasaskan model dan menghasilkan data berat sebelah untuk dianalisis. Walau bagaimanapun, penggunaannya dalam pembetulan PVB belum disiasat sebelum ini. Objektif kajian adalah untuk menyiasat IPB dalam konteks pembetulan PVB di bawah andaian hilang rawak untuk ujian diagnostik binari. IPB telah disesuaikan untuk pembetulan PVB dan diuji serta dibandingkan dengan kaedah sedia ada menggunakan set data simulasi dan klinikal. Keputusan menunjukkan bahawa IPB adalah tepat untuk anggaran SN dan SP kerana ia mempamerkan berat sebelah yang rendah. Walau bagaimanapun, IPB kurang tepat daripada kaedah sedia ada seperti yang ditunjukkan oleh ralat piawai (SE) yang lebih tinggi. Walaupun isu ini, disyorkan untuk menggunakan IPB apabila analisis susulan dengan kaedah analitik data penuh dijangka. Kajian lanjut perlu dilakukan untuk mengurangkan SE."

You can try to replicate this using rollama’s query() function.2

3.9 Querying Multiple Local LLMs

You can easily send a query to multiple LLMs at once in rollama.

q_text = "Provide a brief description of hypertension."
q_response = query(q_text, c(llama, "gemma2:2b", "phi3:3.8b", "mistral:7b"),
                   output = "data.frame", screen = FALSE,
                   model_params = list(seed = 123))
q_response

Here, we saved the output as data.frame, which can be easily accessed later. We also included model_params = list(seed = 123) to get consistently generated texts for the query. You can set the seed for the whole R session by using options(rollama_seed = 123) function, which can be placed right after library(rollama).

The responses for the query are displayed in Table 3.1.

knitr::kable(q_response, format = "html",
             caption = 'Query - "Provide a brief description of hypertension."',
             col.names = c("Model", "Role", "Response"))
Table 3.1: Query - "Provide a brief description of hypertension."
Model Role Response
llama3.2:3b assistant Hypertension, also known as high blood pressure, is a medical condition in which the force of blood against the artery walls is consistently too high. It can lead to damage and strain on the heart, kidneys, brain, and other vital organs.\n\nNormally, when the heart beats, it pumps blood into the arteries, causing them to constrict (or narrow) slightly. As the heart relaxes, the arteries dilate (or widen), allowing fresh blood to flow in. In people with hypertension, this process is disrupted, leading to:\n\n1. Arteries that remain permanently narrowed or constricted.\n2. Blood vessels that are stiff and less able to stretch.\n\nHigh blood pressure increases the risk of various health problems, including heart attack, stroke, kidney disease, and vision loss. It can also lead to organ damage over time if left untreated.\n\nHypertension is often asymptomatic, making it crucial for people with high blood pressure to monitor their condition regularly through regular check-ups and at-home blood pressure monitoring.
gemma2:2b assistant Hypertension, also known as high blood pressure, is a condition where the force of your blood against your artery walls is consistently too high. \n\n**Here's a simplified breakdown:**\n\n* **High Blood Pressure (BP):** Imagine a hose with water flowing through it. In hypertensive people, the water pressure in the hose (blood) is too high, causing strain on the walls and potentially leading to problems. \n* **Causes:** Many factors contribute to hypertension, including genetics, lifestyle choices (diet, exercise), stress, and underlying medical conditions like diabetes or kidney disease.\n* **Consequences:** Uncontrolled hypertension damages blood vessels over time, increasing risk of heart attack, stroke, vision loss, and other serious health problems. \n\n**It's important to note that:** Hypertension can be silent in early stages, so regular checkups are crucial. \n\n\nIf you have concerns about your blood pressure, please consult a healthcare professional for accurate diagnosis and guidance.\n
phi3:3.8b assistant Hypertension, also known as high blood pressure, is a common condition in which the force against your artery walls is consistently too high. This can lead to health problems such as heart disease and stroke if not managed properly. There are two types: primary (essential) hypertension, often caused by factors like genetics or lifestyle; and secondary hypertension due to an underlying condition that affects the kidneys, arteries, heart, or endocrine system. It is typically asymptomatic but can be detected through routine screening.
mistral:7b assistant Hypertension, also known as high blood pressure, is a long-term medical condition in which the force of blood against the walls of arteries is consistently too high. This pressure causes the heart to work harder than normal to pump blood throughout the body, potentially leading to health problems such as heart disease, stroke, kidney failure, and other complications if left untreated. Hypertension is typically categorized as either primary (essential) hypertension or secondary hypertension, with primary being more common and having no identifiable underlying cause, while secondary hypertension is caused by an underlying condition such as kidney problems, tumors, or certain medications.

and you can get well-formatted text if it is processed as Markdown,

cat(q_response$response[2])

Hypertension, also known as high blood pressure, is a condition where the force of your blood against your artery walls is consistently too high.

Here’s a simplified breakdown:

  • High Blood Pressure (BP): Imagine a hose with water flowing through it. In hypertensive people, the water pressure in the hose (blood) is too high, causing strain on the walls and potentially leading to problems.
  • Causes: Many factors contribute to hypertension, including genetics, lifestyle choices (diet, exercise), stress, and underlying medical conditions like diabetes or kidney disease.
  • Consequences: Uncontrolled hypertension damages blood vessels over time, increasing risk of heart attack, stroke, vision loss, and other serious health problems.

It’s important to note that: Hypertension can be silent in early stages, so regular checkups are crucial.

If you have concerns about your blood pressure, please consult a healthcare professional for accurate diagnosis and guidance.

3.10 Deep-dive: How It Works

In progress …

References

Aria, M. (2020). pubmedR: Gathering metadata about publications, grants, clinical trials from PubMed database. Retrieved from https://github.com/massimoaria/pubmedR
Aria, M., & Cuccurullo, C. (2017). Bibliometrix: An r-tool for comprehensive science mapping analysis. Journal of Informetrics. https://doi.org/10.1016/j.joi.2017.08.007
Aria, M., & Cuccurullo, C. (2024). Bibliometrix: Comprehensive science mapping analysis. Retrieved from https://www.bibliometrix.org
Gruber, J. B., & Weber, M. (2024). Rollama: Communicate with ollama to run large language models locally. Retrieved from https://jbgruber.github.io/rollama/
Lin, H., & Safi, T. (2024). Ollamar: Ollama language models. Retrieved from https://hauselin.github.io/ollama-r/
Ruiz, E. (2024). Mall: Run multiple large language model predictions against a table, or vectors. Retrieved from https://mlverse.github.io/mall/

  1. mall relies on ollamar (Lin & Safi, 2024). You can see detailed ollamar code by including preview = TRUE option to mall’s functions.↩︎

  2. Hint: You can see how llm_translate() does it by including preview = TRUE option.↩︎