Friday, June 3, 2022

Electral Powder (ORS based on WHO formula)

Information about Electral Powder

It is used to restore body fluids and electrolytes lost due to dehydration. It can be used by people suffering from gastrointestinal disorders such as diarrhea and vomiting. It acts as an oral rehydration salt (ORS) formula that has been recommended for use by the World Health Organization (WHO). It is also indicated for the treatment of metabolic acidosis. It can be used to treat muscle cramping caused due to lack of water and electrolytes in the body. In some cases, people recovering from illnesses or those suffering from heatstroke are also recommended to use this powder. It can also be taken for dehydration caused due to exertion while exercising or due to excessive loss of water in hot and/or humid weather. In simple terms, ORS is nothing but a mixture of salts and sugar. In diarrhea, your body tends to lose water and electrolytes such as sodium, chloride, potassium, bicarbonate, etc. If the fluid and electrolyte balance in the body is not maintained by replacing the lost salts and water, dehydration occurs. To prevent dehydration, ORS is recommended. The salt and sugar mixture in ORS stimulates water and electrolyte absorption from the gut, thereby aiding in the replacement of the lost salts in case of diarrhea and vomiting. It is considered to be a safe and most effective treatment for diarrhea (both in kids and adults). It usually doesn't cause any side effects. However, if your condition worsens or if the symptoms still persist, it is best to consult your doctor.

Key ingredients

Sodium chloride: 2.6 gm Potassium chloride: 1.5 gm Sodium citrate: 2.9 gm Dextrose anhydrous: 13.5 gm

Key benefits/uses of Electral Powder

Contains sodium chloride which is essential to maintain fluid and electrolyte balance in the body Helps restore the lost electrolytes and water caused due to dehydration Helps in the maintenance of water balance and distribution, acid-base balance, heart function, as well as muscle and nerve cell function Contains potassium which helps maintain kidney and adrenal function Boosts your energy level, thanks to the presence of dextrose anhydrous, the purest form of dextrose (commonly called glucose) Helps in the treatment of diarrhea and vomiting by maintaining water-electrolyte balance Works by neutralizing excess acid in the blood and urine, thus helping in the treatment of metabolic acidosis Improves recovery post an illness in adults as well as older people Is useful to fight and improve symptoms of heatstroke which is quite common during summer Helps improve fluid levels after excessive loss of water caused post exercising

Directions for use

Dissolve the contents of the packet in the amount of drinking water indicated on the packet (which is usually advised to be dissolved in a liter of water). If drinking water is not available or if you are not sure whether the water is drinkable, boil the water for at least 10 minutes and then let it cool. Add the contents. Stir to mix all the ingredients properly and then you can drink it.

Quick tips for Electral Powder

Adults can drink the solution directly from a glass, but for kids, use a spoon or a cup to feed. It is advised to not use a bottle to feed a kid. Do not mix the contents in milk, soup, fruit juices, etc. Always use water. Also, avoid adding extra sugar or salt to the solution. Always make a fresh drink every time and throw away the solution (if there is any unfinished drink). Keeping the drink uncovered or using the drink for more than 24 hours can up the risk of bacterial infections. Go through the ingredients before using it. If you are allergic to it or any of the components, it is advisable to not use it. Be careful to use the right amount of water. If you use too little water, the drink could make diarrhea worse. Do not use tap water as it carries a high risk of contamination which in turn can worsen the condition. Talk to your doctor if you suffer from any health problems such as kidney disease, diabetes, heart disease, hypertension, or severe and uncontrollable diarrhea/vomiting.

Side effects of Electral Powder

It usually doesn’t cause any side effects when taken as advised by your doctor. However, if you experience any symptoms or if your condition fails to improve, it is best to consult your doctor. Remember to take it as advised by your doctor to reap its benefits.

Storage and safety information

Read the label carefully before use. Keep out of reach of the children. Store in a cool dry place. Use under medical supervision.
Tags: Medicine,

Betamethasone (Salt Information)

Betamethasone

Betamethasone is a steroid medication. It is used for a number of diseases including rheumatic disorders such as rheumatoid arthritis and systemic lupus erythematosus, skin diseases such as dermatitis and psoriasis, allergic conditions such as asthma and angioedema, preterm labor to speed the development of the baby's lungs, Crohn's disease, cancers such as leukemia, and along with fludrocortisone for adrenocortical insufficiency, among others. It can be taken by mouth, injected into a muscle, or applied to the skin topically in cream, lotion, or liquid forms.

Serious side effects include an increased risk of infection, muscle weakness, severe allergic reactions, and psychosis. Long-term use may cause adrenal insufficiency. Stopping the medication suddenly following long-term use may be dangerous. The cream commonly results in increased hair growth and skin irritation.
Betamethasone belongs to the glucocorticoid class of medication. It is a stereoisomer of dexamethasone, the two compounds differing only in the spatial configuration of the methyl group at position 16 (see steroid nomenclature).

Betamethasone was patented in 1958, and approved for medical use in the United States in 1961. The cream and ointment are on the World Health Organization's List of Essential Medicines. It is available as a generic medication. In the United States, the pills and injectable solutions are more expensive than the cream.

Forms

Betamethasone is available in a number of compound forms: - betamethasone dipropionate (branded as Diprosone, Diprolene, Celestamine, Procort (in Pakistan), and others), - betamethasone sodium phosphate (branded as Bentelan in Italy) and - betamethasone valerate (branded as Audavate, Betnovate, Celestone, Fucibet, and others). - In the United States and Canada, betamethasone is mixed with clotrimazole and sold as Lotrisone and Lotriderm. - It is also available in combination with salicylic acid (branded as Diprosalic) for using in psoriatic skin conditions. - In some countries, it is also sold mixed with both clotrimazole and gentamicin to add an antibacterial agent to the mix. - Betamethasone sodium phosphate mixed with betamethasone acetate is available in the United States as Celestone Soluspan.
Tags: Medicine,

Povidone-Iodine Ointment USP 5% w-by-w

Povidone-iodine (PVP-I), also known as iodopovidone, is an antiseptic used for skin disinfection before and after surgery. It may be used both to disinfect the hands of healthcare providers and the skin of the person they are caring for. It may also be used for minor wounds. It may be applied to the skin as a liquid or a powder.

Side effects include skin irritation and sometimes swelling. If used on large wounds, kidney problems, high blood sodium, and metabolic acidosis may occur. It is not recommended in women who are less than 32 weeks pregnant. Frequent use is not recommended in people with thyroid problems or are taking lithium.

Povidone-iodine is a chemical complex of povidone, hydrogen iodide, and elemental iodine. It contains 10% Povidone, with total iodine species equaling 10,000 ppm or 1% total titratable iodine. It works by releasing iodine which results in the death of a range of microorganisms.

Povidone-iodine came into commercial use in 1955. It is on the World Health Organization's List of Essential Medicines. Povidone-iodine is available over the counter. It is sold under a number of brand names including Betadine.
Tags: Medicine,

Nanoderm 5 (Topical Cream)

Nanoderm 5C Cream

Price: 80.00 INR

BRAND: Austro labs

PER PACK: 15gm

CONTENT:
1. Iodochlorhydroxyquin
2. Clotrimazole
3. Tolnaftate
4. Gentamicin
5. Clobetasol Propionate

1: Iodochlorhydroxyquin

Clioquinol (iodochlorhydroxyquin) is an antifungal drug and antiprotozoal drug. It is neurotoxic in large doses. It is a member of a family of drugs called hydroxyquinolines which inhibit certain enzymes related to DNA replication. The drugs have been found to have activity against both viral and protozoal infections. A 1964 report described the use of clioquinol in both the treatment and prevention of shigella infection and Entamoeba histolytica infection in institutionalized individuals at Sonoma State Hospital in California. The report indicates 4000 individuals were treated over a 4-year period with few side effects. Several recently reported journal articles describing its use as an antiprotozoal include: # A 2005 reference to its use in treating a Dutch family for Entamoeba histolytica infection. # A 2004 reference to its use in the Netherlands in the treatment of Dientamoeba fragilis infection. # A 1979 reference to the use in Zaire in the treatment of Entamoeba histolytica infection.

Use in neurodegenerative diseases

Research at UCSF indicates that clioquinol appears to block the genetic action of Huntington's disease in mice and in cell culture. Recent animal studies have shown that clioquinol can reverse the progression of Alzheimer's, Parkinson's and Huntington's diseases. According to Siegfried Hekimi and colleagues at McGill's Department of Biology, clioquinol acts directly on a protein called Clk-1, often informally called “clock-1,” and might slow down the aging process. They theorize that this may explain the apparent ability of the drug to be effective in the above conditions, but warn against individuals experimenting with this drug. In addition, a study performed in Drosophila demonstrates that clioquinol can slow the pathogenesis of tauopathy model by removing the excessive zinc in the cell.

2: Clotrimazole

Clotrimazole, sold under the brand name Lotrimin, among others, is an antifungal medication. It is used to treat vaginal yeast infections, oral thrush, diaper rash, tinea versicolor, and types of ringworm including athlete's foot and jock itch. It can be taken by mouth or applied as a cream to the skin or in the vagina. Common side effects when taken by mouth include nausea and itchiness. When applied to the skin, common side effects include redness and a burning sensation. In pregnancy, use on the skin or in the vagina is believed to be safe. There is no evidence of harm when used by mouth during pregnancy but this has been less well studied. When used by mouth, greater care should be taken in those with liver problems. It is in the azole class of medications and works by disrupting the fungal cell membrane. Clotrimazole was discovered in 1969. It is on the World Health Organization's List of Essential Medicines. It is available as a generic medication.

Pharmacodynamics

Clotrimazole is an imidazole derivative which works by inhibiting the growth of individual Candida or fungal cells by altering the permeability of the fungal cell wall. It binds to phospholipids in the cell membrane and inhibits the biosynthesis of ergosterol and other sterols required for cell membrane production. Clotrimazole may slow fungal growth or result in fungal cell death.

3: Tolnaftate

Tolnaftate (INN) is a synthetic thiocarbamate used as an anti-fungal agent that may be sold without medical prescription in most jurisdictions. It is supplied as a cream, powder, spray, liquid, and liquid aerosol. Tolnaftate is used to treat fungal conditions such as jock itch, athlete's foot and ringworm.

Mechanism

Although the exact mechanism of action is not entirely known, it is believed to inhibit squalene epoxidase, an important enzyme in the biosynthetic pathway of ergosterol (a key component of the fungal cell membrane) in a similar way to terbinafine.

4: Gentamicin

Gentamicin is an antibiotic used to treat several types of bacterial infections. This may include bone infections, endocarditis, pelvic inflammatory disease, meningitis, pneumonia, urinary tract infections, and sepsis among others. It is not effective for gonorrhea or chlamydia infections. It can be given intravenously, by injection into a muscle, or topically. Topical formulations may be used in burns or for infections of the outside of the eye. It is often only used for two days until bacterial cultures determine what specific antibiotics the infection is sensitive to. The dose required should be monitored by blood testing. Gentamicin can cause inner ear problems and kidney problems. The inner ear problems can include problems with balance and hearing loss. These problems may be permanent. If used during pregnancy, it can cause harm to the developing baby. However, it appears to be safe for use during breastfeeding. Gentamicin is a type of aminoglycoside. It works by disrupting the ability of the bacteria to make proteins, which typically kills the bacteria. Gentamicin is naturally produced by the bacterium Micromonospora purpurea, was patented in 1962, approved for medical use in 1964. The antibiotic is collected from the culture of the Micromonospora by perforating the cell wall of the bacterium. Current research is underway to understand the biosynthesis of this antibiotic in an attempt to increase expression and force secretion of gentamicin for higher titer. Gentamicin is on the World Health Organization's List of Essential Medicines. The World Health Organization classifies gentamicin as critically important for human medicine. It is available as a generic medication.

5: Clobetasol Propionate

Clobetasol propionate is a corticosteroid used to treat skin conditions such as eczema, contact dermatitis, seborrheic dermatitis, and psoriasis. It is applied to the skin as a cream, ointment, or shampoo. Use should be short term and only if other weaker corticosteroids are not effective. Use is not recommended in rosacea or perioral dermatitis. Common side effects include skin irritation, dry skin, redness, pimples, and telangiectasia. Serious side effects may include adrenal suppression, allergic reactions, cellulitis, and Cushing's syndrome. Use in pregnancy and breastfeeding is of unclear safety. Clobetasol is believed to work by activating steroid receptors. It is a US Class I (Europe: class IV) corticosteroid, making it one of the strongest available. Clobetasol propionate was patented in 1968 and came into medical use in 1978. It is available as a generic medication. In 2019, it was the 180th most commonly prescribed medication in the United States, with more than 3 million prescriptions.
Tags: Medicine,

Vectors Introduction Quiz (Jun 2022)

Ques 1:

Ques 2:
Ans 2:
Ques 3:
Ques 4:
Ques 5:
Ans 5:
Results:
Tags: Mathematical Foundations for Data Science,

Vectors Intro (4 Practice Questions, Jun 2022)

Ques 1:
Ques 2:
Ques 3:
Ques 4:
Tags: Mathematical Foundations for Data Science,

Thursday, June 2, 2022

Creating a Taxonomy for BBC News Articles (Part 2)

Note

In this part, we cheat a little bit, look at the data set for number of categories that have been already defined for the news articles and then we apply SentenceTransformer to encode and AgglomerativeClustering to identify hierarchical groups for these articles. import pandas as pd import numpy as np from sklearn.metrics.pairwise import cosine_similarity from sentence_transformers import SentenceTransformer from collections import Counter import warnings warnings.filterwarnings('ignore') from matplotlib import pyplot as plt from scipy.cluster.hierarchy import dendrogram from sklearn.cluster import AgglomerativeClustering df1 = pd.read_csv('bbc_news_train.csv') df1.columns Index(['ArticleId', 'Text', 'Category'], dtype='object')

Peeking into the data set

Counter(df1['Category']) Counter({'business': 336, 'tech': 261, 'politics': 274, 'sport': 346, 'entertainment': 273}) model = SentenceTransformer('distilbert-base-nli-mean-tokens') %%time sentences = df1['Text'].values.tolist() sentences_df = pd.DataFrame({"sentences": sentences}) tokenized = sentences_df['sentences'].apply(lambda x: model.encode([x])[0]) CPU times: total: 10min 56s Wall time: 5min 29s tokenized_list = tokenized.values.tolist() cols = ["feature_" + str(i) for i in range(768)] tokenized_df = pd.DataFrame(columns = cols, data = tokenized_list) X = tokenized_df # setting distance_threshold=0 ensures we compute the full tree. # model = AgglomerativeClustering(distance_threshold=0, n_clusters=None) # Setting number of clusters to 5 as per the categories present in the training data set. # model = AgglomerativeClustering(distance_threshold=0, n_clusters=5) # ValueError: Exactly one of n_clusters and distance_threshold has to be set, and the other needs to be None. # By default, parameter "compute_distances" is False and in such case, we would not be able to produce Dendrogram so we set this parameter to True. model = AgglomerativeClustering(distance_threshold=None, n_clusters=5, compute_distances=True) pred = model.fit_predict(X) print(pred) print(len(pred)) print(len(Counter(pred).keys())) [0 1 3 ... 1 3 3] 1490 5 def plot_dendrogram(model, **kwargs): # Create linkage matrix and then plot the dendrogram # create the counts of samples under each node counts = np.zeros(model.children_.shape[0]) n_samples = len(model.labels_) for i, merge in enumerate(model.children_): current_count = 0 for child_idx in merge: if child_idx < n_samples: current_count += 1 # leaf node else: current_count += counts[child_idx - n_samples] counts[i] = current_count linkage_matrix = np.column_stack( [model.children_, model.distances_, counts] ).astype(float) # Plot the corresponding dendrogram dendrogram(linkage_matrix, **kwargs) return linkage_matrix df1['pred'] = pred df1.to_csv('output_' + str(round(time())) + ".csv", index = False) plt.title("Hierarchical Clustering Dendrogram") # plot the top three levels of the dendrogram linkage_matrix = plot_dendrogram(model, truncate_mode="level", p=3) plt.xlabel("Number of points in node (or index of point if no parenthesis).") plt.show()

Analyzing the output in Excel

Table View

Now in Pivot Table

Tags: Technology,Natural Language Processing,Machine Learning,Python,

Creating a Taxonomy for BBC News Articles (Part 1 (20220602))

Creating the Conda environment and the ipykernel.

Refer this link: Creating environment and kernel for sentence_transformers

Code

import pandas as pd import numpy as np from sklearn.metrics.pairwise import cosine_similarity from sentence_transformers import SentenceTransformer import warnings warnings.filterwarnings('ignore') df1 = pd.read_csv('bbc_news_train.csv') Note: You can download the BBC News data set from this GitHub repository: bbc_news df1.columns Index(['ArticleId', 'Text', 'Category'], dtype='object') SentenceTransformer._version 1 model = SentenceTransformer('distilbert-base-nli-mean-tokens') %%time sentences = df1['Text'].values.tolist() sentences_df = pd.DataFrame({"sentences": sentences}) tokenized = sentences_df['sentences'].apply(lambda x: model.encode([x])[0]) CPU times: total: 11min 6s Wall time: 5min 35s tokenized_list = tokenized.values.tolist() cols = ["feature_" + str(i) for i in range(768)] Note: DistilBERT based SentenceTransformer produces 768 features. tokenized_df = pd.DataFrame(columns = cols, data = tokenized_list) import numpy as np from matplotlib import pyplot as plt from scipy.cluster.hierarchy import dendrogram from sklearn.datasets import load_iris from sklearn.cluster import AgglomerativeClustering def plot_dendrogram(model, **kwargs): # Create linkage matrix and then plot the dendrogram # create the counts of samples under each node counts = np.zeros(model.children_.shape[0]) n_samples = len(model.labels_) for i, merge in enumerate(model.children_): current_count = 0 for child_idx in merge: if child_idx < n_samples: current_count += 1 # leaf node else: current_count += counts[child_idx - n_samples] counts[i] = current_count linkage_matrix = np.column_stack( [model.children_, model.distances_, counts] ).astype(float) # Plot the corresponding dendrogram dendrogram(linkage_matrix, **kwargs) X = tokenized_df # setting distance_threshold=0 ensures we compute the full tree. model = AgglomerativeClustering(distance_threshold=0, n_clusters=None) model = model.fit(X) plt.title("Hierarchical Clustering Dendrogram") # plot the top three levels of the dendrogram plot_dendrogram(model, truncate_mode="level", p=3) plt.xlabel("Number of points in node (or index of point if no parenthesis).") plt.show()
Tags: Technology,Natural Language Processing,Machine Learning,Python,

Wednesday, June 1, 2022

Losing your body, losing your self (from the book: Body Keeps The Score)

Be patient toward all that is unsolved in your heart and try to love the questions themselves.... Live the questions now. Perhaps you will gradually, without noticing it, live along some distant day into the answer.
—Rainer Maria Rilke, Letters to a Young Poet

Sherry walked into my office with her shoulders slumped, her chin nearly touching her chest. Even before we spoke a word, her body was telling me that she was afraid to face the world. I also noticed that her long sleeves only partially covered the scabs on her forearms. After sitting down, she told me in a high-pitched monotone that she couldn’t stop herself from picking at the skin on her arms and chest until she bled.

As far back as Sherry could remember, her mother had run a foster home, and their house was often packed with as many as fifteen strange, disruptive, frightened, and frightening kids who disappeared as suddenly as they arrived. Sherry had grown up taking care of these transient children, feeling that there was no room for her and her needs. “I know I wasn’t wanted,” she told me. “I’m not sure when I first realized that, but I’ve thought about things that my mother said to me, and the signs were always there. She’d tell me, ‘You know, I don’t think you belong in this family. I think they gave us the wrong baby.’ And she’d say it with a smile on her face. But, of course, people often pretend to joke when they say something serious.”
Over the years our research team has repeatedly found that chronic emotional abuse and neglect can be just as devastating as physical abuse and sexual molestation. Sherry turned out to be a living example of these findings: Not being seen, not being known, and having nowhere to turn to feel safe is devastating at any age, but it is particularly destructive for young children, who are still trying to find their place in the world.

Sherry had graduated from college, but she now worked in a joyless clerical job, lived alone with her cats, and had no close friends. When I asked her about men, she told me that her only “relationship” had been with a man who’d kidnapped her while she was on a college vacation in Florida.
He’d held her captive and raped her repeatedly for five consecutive days.
She remembered having been curled up, terrified and frozen for most of that time, until she realized she could try to get away. She escaped by simply walking out while he was in the bathroom. When she called her mother collect for help, her mother refused to take the call. Sherry finally managed to get home with assistance from a domestic violence shelter.
Sherry told me that she’d started to pick at her skin because it gave her some relief from feeling numb. The physical sensations made her feel more alive but also deeply ashamed—she knew she was addicted to these actions but could not stop them. She’d consulted many mental health professionals before me and had been questioned repeatedly about her “suicidal behavior.” She’d also been subjected to involuntary hospitalization by a psychiatrist who refused to treat her unless she could promise that she would never pick at herself again. However, in my experience, patients who cut themselves or pick at their skin like Sherry, are seldom suicidal but are trying to make themselves feel better in the only way they know.
This is a difficult concept for many people to understand. As I discussed in the previous chapter, the most common response to distress is to seek out people we like and trust to help us and give us the courage to go on. We may also calm down by engaging in a physical activity like biking or going to the gym. We start learning these ways of regulating our feelings from the first moment someone feeds us when we’re hungry, covers us when we’re cold, or rocks us when we’re hurt or scared.
But if no one has ever looked at you with loving eyes or broken out in a smile when she sees you; if no one has rushed to help you (but instead said, “Stop crying, or I’ll give you something to cry about”), then you need to discover other ways of taking care of yourself. You are likely to experiment with anything—drugs, alcohol, binge eating, or cutting—that offers some kind of relief.

While Sherry dutifully came to every appointment and answered my questions with great sincerity, I did not feel we were making the sort of vital connection that is necessary for therapy to work. Struck by how frozen and uptight she was, I suggested that she see Liz, a massage therapist I had worked with previously. During their first meeting Liz positioned Sherry on the massage table, then moved to the end of the table and gently held Sherry’s feet. Lying there with her eyes closed, Sherry suddenly yelled in a panic: “Where are you?” Somehow Sherry had lost track of Liz, even though Liz was right there, with her hands on Sherry’s feet.

Sherry was one of the first patients who taught me about the extreme disconnection from the body that so many people with histories of trauma and neglect experience. I discovered that my professional training, with its focus on understanding and insight, had largely ignored the relevance of the living, breathing body, the foundation of our selves. Sherry knew that picking her skin was a destructive thing to do and that it was related to her mother’s neglect, but understanding the source of the impulse made no difference in helping her control it.

LOSING YOUR BODY

Once I was alerted to this, I was amazed to discover how many of my patients told me they could not feel whole areas of their bodies. Sometimes I’d ask them to close their eyes and tell me what I had put into their outstretched hands. Whether it was a car key, a quarter, or a can opener, they often could not even guess what they were holding—their sensory perceptions simply weren’t working. I talked this over with my friend Alexander McFarlane in Australia, who had observed the same phenomenon. In his laboratory in Adelaide he had studied the question: How do we know without looking at it that we’re holding a car key? Recognizing an object in the palm of your hand requires sensing its shape, weight, temperature, texture, and position. Each of those distinct sensory experiences is transmitted to a different part of the brain, which then needs to integrate them into a single perception. McFarlane found that people with PTSD often have trouble putting the picture together. When our senses become muffled, we no longer feel fully alive. In an article called “What Is an Emotion?” (1884), William James, the father of American psychology, reported a striking case of “sensory insensibility” in a woman he interviewed: “I have... no human sensations,” she told him. “[I am] surrounded by all that can render life happy and agreeable, still to me the faculty of enjoyment and of feeling is wanting.... Each of my senses, each part of my proper self, is as it were separated from me and can no longer afford me any feeling; this impossibility seems to depend upon a void which I feel in the front of my head, and to be due to the diminution of the sensibility over the whole surface of my body, for it seems to me that I never actually reach the objects which I touch. All this would be a small matter enough, but for its frightful result, which is that of the impossibility of any other kind of feeling and of any sort of enjoyment, although I experience a need and desire of them that render my life an incomprehensible torture.” This response to trauma raises an important question: How can traumatized people learn to integrate ordinary sensory experiences so that they can live with the natural flow of feeling and feel secure and complete in their bodies?

HOW DO WE KNOW WE’RE ALIVE?

Most early neuroimaging studies of traumatized people were like those we’ve seen in chapter 3; they focused on how subjects reacted to specific reminders of the trauma. Then, in 2004, my colleague Ruth Lanius, who scanned Stan and Ute Lawrence’s brains, posed a new question: What happens in the brains of trauma survivors when they are not thinking about the past? Her studies on the idling brain, the “default state network” (DSN), opened up a whole new chapter in understanding how trauma affects selfawareness, specifically sensory self-awareness. Dr. Lanius recruited a group of sixteen “normal” Canadians to lie in a brain scanner while thinking about nothing in particular. This is not easy for anyone to do—as long as we are awake, our brains are churning—but she asked them to focus their attention on their breathing and try to empty their minds as much as possible. She then repeated the same experiment with eighteen people who had histories of severe, chronic childhood abuse. What is your brain doing when you have nothing in particular on your mind? It turns out that you pay attention to yourself: The default state activates the brain areas that work together to create your sense of “self.” When Ruth looked at the scans of her normal subjects, she found activation of DSN regions that previous researchers had described. I like to call this the Mohawk of self-awareness, the midline structures of the brain, starting out right above our eyes, running through the center of the brain all the way to the back. All these midline structures are involved in our sense of self. The largest bright region at the back of the brain is the posterior cingulate, which gives us a physical sense of where we are - our internal GPS. It is strongly connected to the medial prefrontal cortex (MPFC), the watchtower I discussed in chapter 4. (This connection doesn't show up on the scan because the fMRI can't measure it.) It is also connected with brain areas that register sensations coming from the rest of the body: the insula, which relays messages from the viscera to the emotional centers; the parietal lobes, which integrate sensory information; and the anterior cingulate, which coordinates emotions and thinking. All of these areas contribute to consciousness.
Locating the self. The Mohawk of self-awareness. Starting from the front of the brain (at right), this consists of: the orbital prefrontal cortex, the medial prefrontal cortex, the anterior cingulate, the posterior cingulate, and the insula. In individuals with histories of chronic trauma the same regions show sharply decreased activity, making it difficult to register internal states and assessing the personal relevance of incoming information. The contrast with the scans of the eighteen chronic PTSD patients with severe early-life trauma was startling. There was almost no activation of any of the self-sensing areas of the brain: The MPFC, the anterior cingulate, the parietal cortex, and the insula did not light up at all; the only area that showed a slight activation was the posterior cingulate, which is responsible for basic orientation in space. There could be only one explanation for such results: In response to the trauma itself, and in coping with the dread that persisted long afterward, these patients had learned to shut down the brain areas that transmit the visceral feelings and emotions that accompany and define terror. Yet in everyday life, those same brain areas are responsible for registering the entire range of emotions and sensations that form the foundation of our selfawareness, our sense of who we are. What we witnessed here was a tragic adaptation: In an effort to shut off terrifying sensations, they also deadened their capacity to feel fully alive. The disappearance of medial prefrontal activation could explain why so many traumatized people lose their sense of purpose and direction. I used to be surprised by how often my patients asked me for advice about the most ordinary things, and then by how rarely they followed it. Now I understood that their relationship with their own inner reality was impaired. How could they make decisions, or put any plan into action, if they couldn’t define what they wanted or, to be more precise, what the sensations in their bodies, the basis of all emotions, were trying to tell them? The lack of self-awareness in victims of chronic childhood trauma is sometimes so profound that they cannot recognize themselves in a mirror. Brain scans show that this is not the result of mere inattention: The structures in charge of self-recognition may be knocked out along with the structures related to self-experience. When Ruth Lanius showed me her study, a phrase from my classical high school education came back to me. The mathematician Archimedes, teaching about the lever, is supposed to have said: “Give me a place to stand and I will move the world.” Or, as the great twentieth-century body therapist Moshe Feldenkrais put it: “You can't do what you want till you know what you’re doing.” The implications are clear: to feel present you have to know where you are and be aware of what is going on with you. If the self-sensing system breaks down we need to find ways to reactivate it.

THE SELF-SENSING SYSTEM

It was fascinating to see how much Sherry benefited from her massage therapy. She felt more relaxed and adventurous in her day-to-day life and she was also more relaxed and open with me. She became truly involved in her therapy and was genuinely curious about her behavior, thoughts, and feelings. She stopped picking at her skin, and when summer came she started to spend evenings sitting outside on her stoop, chatting with her neighbors. She even joined a church choir, a wonderful experience of group synchrony. It was at about this time that I met Antonio Damasio at a small think tank that Dan Schacter, the chair of the psychology department at Harvard, had organized. In a series of brilliant scientific articles and books Damasio clarified the relationship among body states, emotions, and survival. A neurologist who has treated hundreds of people with various forms of brain damage, he became fascinated with consciousness and with identifying the areas of the brain necessary for knowing what you feel. He has devoted his career to mapping out what is responsible for our experience of “self.” The Feeling of What Happens is, for me, his most important book, and reading it was a revelation.5 Damasio starts by pointing out the deep divide between our sense of self and the sensory life of our bodies. As he poetically explains, “Sometimes we use our minds not to discover facts, but to hide them.... One of the things the screen hides most effectively is the body, our own body, by which I mean the ins of it, its interiors. Like a veil thrown over the skin to secure its modesty, the screen partially removes from the mind the inner states of the body, those that constitute the flow of life as it wanders in the journey of each day.” He goes on to describe how this “screen” can work in our favor by enabling us to attend to pressing problems in the outside world. Yet it has a cost: "It tends to prevent us from sensing the possible origin and nature of what we call self." Building on the century-old work of William James, Damasio argues that the core of our self-awareness rests on the physical sensations that convey the inner states of the body: [P]rimordial feelings provide a direct experience of one’s own living body, wordless, unadorned, and connected to nothing but sheer existence. These primordial feelings reflect the current state of the body along varied dimensions,... along the scale that ranges from pleasure to pain, and they originate at the level of the brain stem rather than the cerebral cortex. All feelings of emotion are complex musical variations on primordial feelings. Our sensory world takes shape even before we are born. In the womb we feel amniotic fluid against our skin, we hear the faint sounds of rushing blood and a digestive tract at work, we pitch and roll with our mother’s movements. After birth, physical sensation defines our relationship to ourselves and to our surroundings. We start off being our wetness, hunger, satiation, and sleepiness. A cacophony of incomprehensible sounds and images presses in on our pristine nervous system. Even after we acquire consciousness and language, our bodily sensing system provides crucial feedback on our moment-to-moment condition. Its constant hum communicates changes in our viscera and in the muscles of our face, torso, and extremities that signal pain and comfort, as well as urges such as hunger and sexual arousal. What is taking place around us also affects our physical sensations. Seeing someone we recognize, hearing particular sounds—a piece of music, a siren—or sensing a shift in temperature all change our focus of attention and, without our being aware of it, prime our subsequent thoughts and actions. As we have seen, the job of the brain is to constantly monitor and evaluate what is going on within and around us. These evaluations are transmitted by chemical messages in the bloodstream and electrical messages in our nerves, causing subtle or dramatic changes throughout the body and brain. These shifts usually occur entirely without conscious input or awareness: The subcortical regions of the brain are astoundingly efficient in regulating our breathing, heartbeat, digestion, hormone secretion, and immune system. However, these systems can become overwhelmed if we are challenged by an ongoing threat, or even the perception of threat. This accounts for the wide array of physical problems researchers have documented in traumatized people. Yet our conscious self also plays a vital role in maintaining our inner equilibrium: We need to register and act on our physical sensations to keep our bodies safe. Realizing we’re cold compels us to put on a sweater; feeling hungry or spacey tells us our blood sugar is low and spurs us to get a snack; the pressure of a full bladder sends us to the bathroom. Damasio points out that all of the brain structures that register background feelings are located near areas that control basic housekeeping functions, such as breathing, appetite, elimination, and sleep/wake cycles: “This is because the consequences of having emotion and attention are entirely related to the fundamental business of managing life within the organism. It is not possible to manage life and maintain homeostatic balance without data on the current state of the organism’s body.”9 Damasio calls these housekeeping areas of the brain the “proto-self,” because they create the “wordless knowledge” that underlies our conscious sense of self.

THE SELF UNDER THREAT

In 2000 Damasio and his colleagues published an article in the world’s foremost scientific publication, Science, which reported that reliving a strong negative emotion causes significant changes in the brain areas that receive nerve signals from the muscles, gut, and skin—areas that are crucial for regulating basic bodily functions. The team’s brain scans showed that recalling an emotional event from the past causes us to actually reexperience the visceral sensations felt during the original event. Each type of emotion produced a characteristic pattern, distinct from the others. For example, a particular part of the brain stem was “active in sadness and anger, but not in happiness or fear.”10 All of these brain regions are below the limbic system, to which emotions are traditionally assigned, yet we acknowledge their involvement every time we use one of the common expressions that link strong emotions with the body: “You make me sick”; “It made my skin crawl”; “I was all choked up”; “My heart sank”; “He makes me bristle.” The elementary self system in the brain stem and limbic system is massively activated when people are faced with the threat of annihilation, which results in an overwhelming sense of fear and terror accompanied by intense physiological arousal. To people who are reliving a trauma, nothing makes sense; they are trapped in a life-or-death situation, a state of paralyzing fear or blind rage. Mind and body are constantly aroused, as if they are in imminent danger. They startle in response to the slightest noises and are frustrated by small irritations. Their sleep is chronically disturbed, and food often loses its sensual pleasures. This in turn can trigger desperate attempts to shut those feelings down by freezing and dissociation. How do people regain control when their animal brains are stuck in a fight for survival? If what goes on deep inside our animal brains dictates how we feel, and if our body sensations are orchestrated by subcortical (subconscious) brain structures, how much control over them can we actually have?

AGENCY: OWNING YOUR LIFE

“Agency” is the technical term for the feeling of being in charge of your life: knowing where you stand, knowing that you have a say in what happens to you, knowing that you have some ability to shape your circumstances. The veterans who put their fists through drywall at the VA were trying to assert their agency—to make something happen. But they ended up feeling even more out of control, and many of these onceconfident men were trapped in a cycle between frantic activity and immobility. Agency starts with what scientists call interoception, our awareness of our subtle sensory, body-based feelings: the greater that awareness, the greater our potential to control our lives. Knowing what we feel is the first step to knowing why we feel that way. If we are aware of the constant changes in our inner and outer environment, we can mobilize to manage them. But we can’t do this unless our watchtower, the MPFC, learns to observe what is going on inside us. This is why mindfulness practice, which strengthens the MPFC, is a cornerstone of recovery from trauma.12 After I saw the wonderful movie March of the Penguins, I found myself thinking about some of my patients. The penguins are stoic and endearing, and it’s tragic to learn how, from time immemorial, they have trudged seventy miles inland from the sea, endured indescribable hardships to reach their breeding grounds, lost numerous viable eggs to exposure, and then, almost starving, dragged themselves back to the ocean. If penguins had our frontal lobes, they would have used their little flippers to build igloos, devised a better division of labor, and reorganized their food supplies. Many of my patients have survived trauma through tremendous courage and persistence, only to get into the same kinds of trouble over and over again. Trauma has shut down their inner compass and robbed them of the imagination they need to create something better. The neuroscience of selfhood and agency validates the kinds of somatic therapies that my friends Peter Levine13 and Pat Ogden14 have developed. I’ll discuss these and other sensorimotor approaches in more detail in part V, but in essence their aim is threefold: 1: to draw out the sensory information that is blocked and frozen by trauma; 2: to help patients befriend (rather than suppress) the energies released by that inner experience; 3: to complete the self-preserving physical actions that were thwarted when they were trapped, restrained, or immobilized by terror. Our gut feelings signal what is safe, life sustaining, or threatening, even if we cannot quite explain why we feel a particular way. Our sensory interiority continuously sends us subtle messages about the needs of our organism. Gut feelings also help us to evaluate what is going on around us. They warn us that the guy who is approaching feels creepy, but they also convey that a room with western exposure surrounded by daylilies makes us feel serene. If you have a comfortable connection with your inner sensations—if you can trust them to give you accurate information—you will feel in charge of your body, your feelings, and your self. However, traumatized people chronically feel unsafe inside their bodies: The past is alive in the form of gnawing interior discomfort. Their bodies are constantly bombarded by visceral warning signs, and, in an attempt to control these processes, they often become expert at ignoring their gut feelings and in numbing awareness of what is played out inside. They learn to hide from their selves. The more people try to push away and ignore internal warning signs, the more likely they are to take over and leave them bewildered, confused, and ashamed. People who cannot comfortably notice what is going on inside become vulnerable to respond to any sensory shift either by shutting down or by going into a panic—they develop a fear of fear itself. We now know that panic symptoms are maintained largely because the individual develops a fear of the bodily sensations associated with panic attacks. The attack may be triggered by something he or she knows is irrational, but fear of the sensations keeps them escalating into a full-body emergency. “Scared stiff” and “frozen in fear” (collapsing and going numb) describe precisely what terror and trauma feel like. They are its visceral foundation. The experience of fear derives from primitive responses to threat where escape is thwarted in some way. People’s lives will be held hostage to fear until that visceral experience changes. The price for ignoring or distorting the body’s messages is being unable to detect what is truly dangerous or harmful for you and, just as bad, what is safe or nourishing. Self-regulation depends on having a friendly relationship with your body. Without it you have to rely on external regulation—from medication, drugs like alcohol, constant reassurance, or compulsive compliance with the wishes of others. Many of my patients respond to stress not by noticing and naming it but by developing migraine headaches or asthma attacks.15 Sandy, a middle-aged visiting nurse, told me she’d felt terrified and lonely as a child, unseen by her alcoholic parents. She dealt with this by becoming deferential to everybody she depended on (including me, her therapist). Whenever her husband made an insensitive remark, she would come down with an asthma attack. By the time she noticed that she couldn’t breathe, it was too late for an inhaler to be effective, and she had to be taken to the emergency room. Suppressing our inner cries for help does not stop our stress hormones from mobilizing the body. Even though Sandy had learned to ignore her relationship problems and block out her physical distress signals, they showed up in symptoms that demanded her attention. Her therapy focused on identifying the link between her physical sensations and her emotions, and I also encouraged her to enroll in a kickboxing program. She had no emergency room visits during the three years she was my patient. Somatic symptoms for which no clear physical basis can be found are ubiquitous in traumatized children and adults. They can include chronic back and neck pain, fibromyalgia, migraines, digestive problems, spastic colon/irritable bowel syndrome, chronic fatigue, and some forms of asthma.16 Traumatized children have fifty times the rate of asthma as their nontraumatized peers. Studies have shown that many children and adults with fatal asthma attacks were not aware of having breathing problems before the attacks.

ALEXITHYMIA: NO WORDS FOR FEELINGS

I had a widowed aunt with a painful trauma history who became an honorary grandmother to our children. She came on frequent visits that were marked by much doing—making curtains, rearranging kitchen shelves, sewing children’s clothes—and very little talking. She was always eager to please, but it was difficult to figure out what she enjoyed. After several days of exchanging pleasantries, conversation would come to a halt, and I’d have to work hard to fill the long silences. On the last day of her visits I’d drive her to the airport, where she’d give me a stiff good-bye hug while tears streamed down her face. Without a trace of irony she’d then complain that the cold wind at Logan International Airport made her eyes water. Her body felt the sadness that her mind couldn’t register—she was leaving our young family, her closest living relatives. Psychiatrists call this phenomenon alexithymia—Greek for not having words for feelings. Many traumatized children and adults simply cannot describe what they are feeling because they cannot identify what their physical sensations mean. They may look furious but deny that they are angry; they may appear terrified but say that they are fine. Not being able to discern what is going on inside their bodies causes them to be out of touch with their needs, and they have trouble taking care of themselves, whether it involves eating the right amount at the right time or getting the sleep they need. Like my aunt, alexithymics substitute the language of action for that of emotion. When asked, “How would you feel if you saw a truck coming at you at eighty miles per hour?” most people would say, “I’d be terrified” or “I’d be frozen with fear.” An alexithymic might reply, “How would I feel? I don’t know. . . . I’d get out of the way.”18 They tend to register emotions as physical problems rather than as signals that something deserves their attention. Instead of feeling angry or sad, they experience muscle pain, bowel irregularities, or other symptoms for which no cause can be found. About three quarters of patients with anorexia nervosa, and more than half of all patients with bulimia, are bewildered by their emotional feelings and have great difficulty describing them.19 When researchers showed pictures of angry or distressed faces to people with alexithymia, they could not figure out what those people were feeling. One of the first people who taught me about alexithymia was the psychiatrist Henry Krystal, who worked with more than a thousand Holocaust survivors in his effort to understand massive psychic trauma. Krystal, himself a concentration camp survivor, found that many of his patients were professionally successful, but their intimate relationships were bleak and distant. Suppressing their feelings had made it possible to attend to the business of the world, but at a price. They learned to shut down their once overwhelming emotions, and, as a result, they no longer recognized what they were feeling. Few of them had any interest in therapy. Paul Frewen at the University of Western Ontario did a series of brain scans of people with PTSD who suffered from alexithymia. One of the participants told him: “I don’t know what I feel, it’s like my head and body aren’t connected. I’m living in a tunnel, a fog, no matter what happens it’s the same reaction—numbness, nothing. Having a bubble bath and being burned or raped is the same feeling. My brain doesn’t feel.” Frewen and his colleague Ruth Lanius found that the more people were out of touch with their feelings, the less activity they had in the self-sensing areas of the brain. Because traumatized people often have trouble sensing what is going on in their bodies, they lack a nuanced response to frustration. They either react to stress by becoming “spaced out” or with excessive anger. Whatever their response, they often can’t tell what is upsetting them. This failure to be in touch with their bodies contributes to their well-documented lack of selfprotection and high rates of revictimization23 and also to their remarkable difficulties feeling pleasure, sensuality, and having a sense of meaning. People with alexithymia can get better only by learning to recognize the relationship between their physical sensations and their emotions, much as colorblind people can only enter the world of color by learning to distinguish and appreciate shades of gray. Like my aunt and Henry Krystal’s patients, they usually are reluctant to do that: Most seem to have made an unconscious decision that it is better to keep visiting doctors and treating ailments that don’t heal than to do the painful work of facing the demons of the past.

DEPERSONALIZATION

One step further down on the ladder to self-oblivion is depersonalization— losing your sense of yourself. Ute’s brain scan in chapter 4 is, in its very blankness, a vivid illustration of depersonalization. Depersonalization is common during traumatic experiences. I was once mugged late at night in a park close to my home and, floating above the scene, saw myself lying in the snow with a small head wound, surrounded by three knife-wielding teenagers. I dissociated the pain of their stab wounds on my hands and did not feel the slightest fear as I calmly negotiated for the return of my emptied wallet. I did not develop PTSD, partly, I think, because I was intensely curious about having an experience I had studied so closely in others, and partly because I had the delusion that I would be able make a drawing of my muggers to show to the police. Of course, they were never caught, but my fantasy of revenge must have given me a satisfying sense of agency. Traumatized people are not so fortunate and feel separated from their bodies. One particularly good description of depersonalization comes from the German psychoanalyst Paul Schilder, writing in Berlin in 1928:24 “To the depersonalized individual the world appears strange, peculiar, foreign, dream-like. Objects appear at times strangely diminished in size, at times flat. Sounds appear to come from a distance. . . . The emotions likewise undergo marked alteration. Patients complain that they are capable of experiencing neither pain nor pleasure. . . . They have become strangers to themselves.” I was fascinated to learn that a group of neuroscientists at the University of Geneva25 had induced similar out-of-body experiences by delivering mild electric current to a specific spot in the brain, the temporal parietal junction. In one patient this produced a sensation that she was hanging from the ceiling, looking down at her body; in another it induced an eerie feeling that someone was standing behind her. This research confirms what our patients tell us: that the self can be detached from the body and live a phantom existence on its own. Similarly, Lanius and Frewen, as well as a group of researchers at the University of Groningen in the Netherlands, did brain scans on people who dissociated their terror and found that the fear centers of the brain simply shut down as they recalled the event.

BEFRIENDING THE BODY

Trauma victims cannot recover until they become familiar with and befriend the sensations in their bodies. Being frightened means that you live in a body that is always on guard. Angry people live in angry bodies. The bodies of child-abuse victims are tense and defensive until they find a way to relax and feel safe. In order to change, people need to become aware of their sensations and the way that their bodies interact with the world around them. Physical self-awareness is the first step in releasing the tyranny of the past. How can people open up to and explore their internal world of sensations and emotions? In my practice I begin the process by helping my patients to first notice and then describe the feelings in their bodies—not emotions such as anger or anxiety or fear but the physical sensations beneath the emotions: pressure, heat, muscular tension, tingling, caving in, feeling hollow, and so on. I also work on identifying the sensations associated with relaxation or pleasure. I help them become aware of their breath, their gestures and movements. I ask them to pay attention to subtle shifts in their bodies, such as tightness in their chests or gnawing in their bellies, when they talk about negative events that they claim did not bother them. Noticing sensations for the first time can be quite distressing, and it may precipitate flashbacks in which people curl up or assume defensive postures. These are somatic reenactments of the undigested trauma and most likely represent the postures they assumed when the trauma occurred. Images and physical sensations may deluge patients at this point, and the therapist must be familiar with ways to stem torrents of sensation and emotion to prevent them from becoming retraumatized by accessing the past. (Schoolteachers, nurses, and police officers are often very skilled at soothing terror reactions because many of them are confronted almost daily with out-of-control or painfully disorganized people.) All too often, however, drugs such as Abilify, Zyprexa, and Seroquel, are prescribed instead of teaching people the skills to deal with such distressing physical reactions. Of course, medications only blunt sensations and do nothing to resolve them or transform them from toxic agents into allies. The most natural way for human beings to calm themselves when they are upset is by clinging to another person. This means that patients who have been physically or sexually violated face a dilemma: They desperately crave touch while simultaneously being terrified of body contact. The mind needs to be reeducated to feel physical sensations, and the body needs to be helped to tolerate and enjoy the comforts of touch. Individuals who lack emotional awareness are able, with practice, to connect their physical sensations to psychological events. Then they can slowly reconnect with themselves.

CONNECTING WITH YOURSELF, CONNECTING WITH OTHERS

I’ll end this chapter with one final study that demonstrates the cost of losing your body. After Ruth Lanius and her group scanned the idling brain, they focused on another question from everyday life: What happens in chronically traumatized people when they make face-to-face contact? Many patients who come to my office are unable to make eye contact. I immediately know how distressed they are by their difficulty meeting my gaze. It always turns out that they feel disgusting and that they can’t stand having me see how despicable they are. It never occurred to me that these intense feelings of shame would be reflected in abnormal brain activation. Ruth Lanius once again showed that mind and brain are indistinguishable— what happens in one is registered in the other. Ruth bought an expensive device that presents a video character to a person lying in a scanner. (In this case, the cartoon resembled a kindly Richard Gere.) The figure can approach either head on (looking directly at the person) or at a forty-five-degree angle with an averted gaze. This made it possible to compare the effects of direct eye contact on brain activation with those of an averted gaze. The most striking difference between normal controls and survivors of chronic trauma was in activation of the prefrontal cortex in response to a direct eye gaze. The prefrontal cortex (PFC) normally helps us to assess the person coming toward us, and our mirror neurons help to pick up his intentions. However, the subjects with PTSD did not activate any part of their frontal lobe, which means they could not muster any curiosity about the stranger. They just reacted with intense activation deep inside their emotional brains, in the primitive areas known as the Periaqueductal Gray, which generates startle, hypervigilance, cowering, and other self-protective behaviors. There was no activation of any part of the brain involved in social engagement. In response to being looked at they simply went into survival mode. What does this mean for their ability to make friends and get along with others? What does it mean for their therapy? Can people with PTSD trust a therapist with their deepest fears? To have genuine relationships you have to be able to experience others as separate individuals, each with his or her particular motivations and intentions. While you need to be able to stand up for yourself, you also need to recognize that other people have their own agendas. Trauma can make all that hazy and gray. Reference: Chapter 6 from the book by Bessel van red Kolk titled "The Body Keeps the score (2022)"
Tags: Book Summary,Psychology,

Creating environment and kernel for sentence_transformers

ENV.YML File

name: sentence_transformers channels: - conda-forge dependencies: - python=3.9 - pip - pandas - openpyxl - ipykernel - jupyter - tensorflow - pip: - sentence-transformers

Installation Logs

(base) C:\Users\Ashish Jain\OneDrive\Desktop\jupyter\sentence_encoding_transformers>conda env create -f env.yml Collecting package metadata (repodata.json): done Solving environment: done ==> WARNING: A newer version of conda exists. <== current version: 4.11.0 latest version: 4.13.0 Please update conda by running $ conda update -n base conda Downloading and Extracting Packages qt-main-5.15.2 | 67.6 MB | #### | 100% nltk-3.6.7 | 1.1 MB | #### | 100% gst-plugins-base-1.1 | 2.2 MB | #### | 100% pip-22.1.2 | 1.5 MB | #### | 100% libclang-13.0.1 | 23.7 MB | #### | 100% gstreamer-1.18.5 | 2.1 MB | #### | 100% lz4-c-1.9.3 | 135 KB | #### | 100% toml-0.10.2 | 18 KB | #### | 100% pyqt-5.15.4 | 4.7 MB | #### | 100% libogg-1.3.4 | 34 KB | #### | 100% sip-6.5.1 | 417 KB | #### | 100% pcre-8.45 | 518 KB | #### | 100% zstd-1.5.2 | 1008 KB | #### | 100% gettext-0.19.8.1 | 4.9 MB | #### | 100% pyqt5-sip-12.9.0 | 72 KB | #### | 100% sentence-transformer | 82 KB | #### | 100% libglib-2.70.2 | 3.1 MB | #### | 100% libvorbis-1.3.7 | 267 KB | #### | 100% Preparing transaction: done Verifying transaction: done Executing transaction: / Enabling notebook extension jupyter-js-widgets/extension... - Validating: ok done # # To activate this environment, use # # $ conda activate sentence_transformers # # To deactivate an active environment, use # # $ conda deactivate (base) C:\Users\Ashish Jain\OneDrive\Desktop\jupyter\sentence_encoding_transformers>conda activate sentence_transformers (sentence_transformers) C:\Users\Ashish Jain\OneDrive\Desktop\jupyter\sentence_encoding_transformers>python -m ipykernel install --user --name sentence_transformers Installed kernelspec sentence_transformers in C:\Users\Ashish Jain\AppData\Roaming\jupyter\kernels\sentence_transformers (sentence_transformers) C:\Users\Ashish Jain\OneDrive\Desktop\jupyter\sentence_encoding_transformers>
Tags: Machine Learning, Natural Language Processing, Python, Technology

DistilBERT based Sentence Encoding Transformer


from sentence_transformers import SentenceTransformer


sbert_model = SentenceTransformer('bert-base-nli-mean-tokens')



# timeout                                   Traceback (most recent call last)
# timeout: The read operation timed out
# ConnectionError: HTTPSConnectionPool(host='cdn-lfs.huggingface.co', port=443): Read timed out.

bert-base-nli-mean-tokens model size is roughly: 450 MB.



model = SentenceTransformer('distilbert-base-nli-mean-tokens')



Downloading: 100%
265M/265M [55:31<00:00, 75.6kB/s]
Downloading: 100%
53.0/53.0 [00:00<00:00, 1.41kB/s]
Downloading: 100%
112/112 [00:00<00:00, 2.99kB/s]
Downloading: 100%
466k/466k [00:11<00:00, 80.0kB/s]
Downloading: 100%
450/450 [00:00<00:00, 14.5kB/s]
Downloading: 100%
232k/232k [00:03<00:00, 76.7kB/s]



query = "I had pizza and pasta"
query_vec = model.encode([query])[0]



len(query_vec)



768



input_sentence_1 = "In recent years, a lot of hype has developed around the promise of neural networks and their ability to classify and identify input data, and more recently the ability of certain network architectures to generate original content. Companies large and small are using them for everything from image captioning and self-driving car navigation to identifying solar panels from satellite images and recognizing faces in security camera videos. And luckily for us, many NLP applications of neural nets exist as well. While deep neural networks have inspired a lot of hype and hyperbole, our robot overlords are probably further off than any clickbait cares to admit. Neural networks are, however, quite powerful tools, and you can easily use them in an NLP chatbot pipeline to classify input text, summarize documents, and even generate novel works. This chapter is intended as a primer for those with no experience in neural networks. We don’t cover anything specific to NLP in this chapter, but gaining a basic understanding of what is going on under the hood in a neural network is important for the upcoming chapters. If you’re familiar with the basics of a neural network, you can rest easy in skipping ahead to the next chapter, where you dive back into processing text with the various flavors of neural nets. Although the mathematics of the underlying algorithm, backpropagation, are outside this book’s scope, a high-level grasp of its basic functionality will help you understand language and the patterns hidden within. As the availability of processing power and memory has exploded over the course of the decade, an old technology has come into its own again. First proposed in the 1950s by Frank Rosenblatt, the perceptron1 offered a novel algorithm for finding patterns in data. The basic concept lies in a rough mimicry of the operation of a living neuron cell. As electrical signals flow into the cell through the dendrites (see figure 5.1) into the nucleus, an electric charge begins to build up. When the cell reaches a certain level of charge, it fires, sending an electrical signal out through the axon. However, the dendrites aren’t all created equal. The cell is more “sensitive” to signals through certain dendrites than others, so it takes less of a signal in those paths to fire the axon. The biology that controls these relationships is most certainly beyond the scope of this book, but the key concept to notice here is the way the cell weights incoming signals when deciding when to fire. The neuron will dynamically change those weights in the decision making process over the course of its life. You are going to mimic that process."
print("Char count in input_sentence_1:", len(input_sentence_1))
print("Word Count in input_sentence_1:", len(input_sentence_1.split(" ")))



Char count in input_sentence_1: 2658
Word Count in input_sentence_1: 442



input_sentence_1_vec = model.encode([input_sentence_1])[0]



type(input_sentence_1_vec)



numpy.ndarray



input_sentence_1_vec.shape



(768,)

Tags: Machine Learning, Natural Language Processing, Python, Technology